<commit_before>//
//  CachingImageTests.swift
//  ImageCacheTests
//
//  Created by <NAME> on 06/07/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import XCTest
import ImageCache

class CachingImageTests: XCTestCase {

    override func setUp() {
        super.setUp()

        clearAllCachedImages()
    }
}<commit_msg>Test that caching image on disk returns success<commit_after>//
//  CachingImageTests.swift
//  ImageCacheTests
//
//  Created by <NAME> on 06/07/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import XCTest
import ImageCache
import DiskCache

class CachingImageTests: XCTestCase {

    override func setUp() {
        super.setUp()

        clearAllCachedImages()
    }

    func testCachingImageOnDiskCallsCompletionHandlerWithSuccess() {
        let key = "TestCachingData"
        let image = testImageWithName("Square", fileExtension: "png")

        let completionExpectation = expectationWithDescription("completionHandler called")

        let completionHandler: Result<Void> -> Void = { result in
            if case .Failure(let error) = result {
                XCTFail("Caching image failed: \(error)")
            }

            completionExpectation.fulfill()
        }

        do {
            try imageCache.cacheImage(image, forKey: key, onDisk: true, completionHandler: completionHandler)
        } catch {
            XCTFail("Caching image failed: \(error)")
        }

        waitForExpectationsWithTimeout(expectationTimeout, handler: nil)
    }
}
{'fraction_non_alphanumeric': 0.09986772486772487, 'fraction_numerical': 0.013227513227513227, 'mean_word_length': 2.610978520286396, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '6739163', 'n_tokens_mistral': 454, 'n_tokens_neox': 420, 'n_words': 110}