<commit_before>open class MockService: Service {

    /// If you provide this variable before calling `perform` we will use this instead of the file content.
    public var mockDictionary: Any?
    internal var bundle: Bundle!
    
    public init(mockDictionary: Any? = nil, for bundle: Bundle = Bundle.main) {
        self.mockDictionary = mockDictionary
        self.bundle = bundle
        super.init(configuration: Configuration(baseURL: "mockService"))
    }

    /// This method is overridden to return json or errors like as if we would do a network call.
    override open func performJsonResult<M : Deserializable>(_ call: Call, jsonResult: @escaping (Result<M>) -> ()) {
        if let mockDictionary = mockDictionary {
            jsonResult(.json(mockDictionary))
            return
        }

        guard let mockJSON = JSONReader.parseFile(named: call.path, for: bundle!) else {
            let faroError = FaroError.malformed(info: "Could not find dummy file at \(call.path)")
            printFaroError(faroError)
            jsonResult(.failure(faroError))
            return
        }

        jsonResult(.json(mockJSON))
    }

}<commit_msg>fixed mocking of write requests<commit_after>open class MockService: Service {

    /// If you provide this variable before calling `perform` we will use this instead of the file content.
    public var mockDictionary: Any?
    internal var bundle: Bundle!
    
    public init(mockDictionary: Any? = nil, for bundle: Bundle = Bundle.main) {
        self.mockDictionary = mockDictionary
        self.bundle = bundle
        super.init(configuration: Configuration(baseURL: "mockService"))
    }

    /// This method is overridden to return json or errors like as if we would do a network call.
    override open func performJsonResult<M : Deserializable>(_ call: Call, jsonResult: @escaping (Result<M>) -> ()) {
        if let mockDictionary = mockDictionary {
            jsonResult(.json(mockDictionary))
            return
        }

        guard let mockJSON = JSONReader.parseFile(named: call.path, for: bundle!) else {
            let faroError = FaroError.malformed(info: "Could not find dummy file at \(call.path)")
            printFaroError(faroError)
            jsonResult(.failure(faroError))
            return
        }

        jsonResult(.json(mockJSON))
    }

    /// Always returns ok we cannot do anything else.
    open override func perform(_ writeCall: Call, result: @escaping (WriteResult) -> ()) {
        result(.ok)
    }

}
{'fraction_non_alphanumeric': 0.09181240063593005, 'fraction_numerical': 0.0, 'mean_word_length': 2.6215827338129496, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4899573', 'n_tokens_mistral': 675, 'n_tokens_neox': 645, 'n_words': 223}