Skip to content

Commit 51ed9bf

Browse files
author
Chris
authored
Merge pull request #7 from crelies/dev
more unit tests, fixed xc test manifests
2 parents 6fa244d + f0f6c4a commit 51ed9bf

10 files changed

+102
-1
lines changed

Tests/RemoteImageTests/Extensions/URLSession+RemoteImageURLDataPublisherTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ final class URLSession_RemoteImageURLDataPublisherTests: XCTestCase {
2121
let dataPublisher = urlSession.dataPublisher(for: urlRequest)
2222
XCTAssertEqual(dataPublisher.description, dataTaskPublisher.description)
2323
}
24+
25+
static var allTests = [
26+
("testDataPublisher", testDataPublisher)
27+
]
2428
}

Tests/RemoteImageTests/Models/PhotoKitServiceErrorTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,16 @@ final class PhotoKitServiceErrorTests: XCTestCase {
6161
func testErrorDomain() {
6262
XCTAssertEqual(PhotoKitServiceError.errorDomain, String(describing: PhotoKitService.self))
6363
}
64+
65+
static var allTests = [
66+
("testMissingDataErrorDescription", testMissingDataErrorDescription),
67+
("testMissingDataFailureReason", testMissingDataFailureReason),
68+
("testMissingDataRecoverySuggestion", testMissingDataRecoverySuggestion),
69+
("testMissingDataErrorCode", testMissingDataErrorCode),
70+
("testPhAssetNotFoundErrorDescription", testPhAssetNotFoundErrorDescription),
71+
("testPhAssetNotFoundFailureReason", testPhAssetNotFoundFailureReason),
72+
("testPhAssetNotFoundRecoverySuggestion", testPhAssetNotFoundRecoverySuggestion),
73+
("testPhAssetNotFoundErrorCode", testPhAssetNotFoundErrorCode),
74+
("testErrorDomain", testErrorDomain)
75+
]
6476
}

Tests/RemoteImageTests/Models/RemoteImageServiceErrorTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ final class RemoteImageServiceErrorTests: XCTestCase {
1414
let expectedDescription = "Could not create image from received data"
1515
XCTAssertEqual(description, expectedDescription)
1616
}
17+
18+
static var allTests = [
19+
("testCouldNotCreateImageDescription", testCouldNotCreateImageDescription)
20+
]
1721
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// RemoteImageStateTests.swift
3+
// RemoteImageTests
4+
//
5+
// Created by Christian Elies on 23.02.20.
6+
//
7+
8+
#if canImport(UIKit)
9+
@testable import RemoteImage
10+
import UIKit
11+
import XCTest
12+
13+
final class RemoteImageStateTests: XCTestCase {
14+
func testErrorValue() {
15+
let error = NSError(domain: "MockDomain", code: 1, userInfo: nil)
16+
let state: RemoteImageState = .error(error)
17+
XCTAssertEqual(state.error, error)
18+
}
19+
20+
func testNoErrorValue() {
21+
let state: RemoteImageState = .loading
22+
XCTAssertNil(state.error)
23+
}
24+
25+
func testImageValue() {
26+
let image = UIImage()
27+
let state: RemoteImageState = .image(image)
28+
XCTAssertEqual(state.image, image)
29+
}
30+
31+
func testNoImageValue() {
32+
let state: RemoteImageState = .loading
33+
XCTAssertNil(state.image)
34+
}
35+
36+
static var allTests = [
37+
("testErrorValue", testErrorValue),
38+
("testNoErrorValue", testNoErrorValue),
39+
("testImageValue", testImageValue),
40+
("testNoImageValue", testNoImageValue)
41+
]
42+
}
43+
#endif

Tests/RemoteImageTests/Services/PhotoKitServiceTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,10 @@ final class PhotoKitServiceTests: XCTestCase {
8787
XCTFail("Invalid photo data result")
8888
}
8989
}
90+
91+
static var allTests = [
92+
("testPhotoDataNotFound", testPhotoDataNotFound),
93+
("testPhotoDataFailure", testPhotoDataFailure),
94+
("testPhotoDataSuccess", testPhotoDataSuccess)
95+
]
9096
}

Tests/RemoteImageTests/Services/RemoteImageServiceDependenciesTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ final class RemoteImageServiceDependenciesTests: XCTestCase {
1515
XCTAssertTrue(dependencies.photoKitService is PhotoKitService)
1616
XCTAssertTrue(dependencies.remoteImageURLDataPublisher is URLSession)
1717
}
18+
19+
static var allTests = [
20+
("testInitialization", testInitialization)
21+
]
1822
}

Tests/RemoteImageTests/Services/RemoteImageServiceFactoryTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ final class RemoteImageServiceFactoryTests: XCTestCase {
1414
let service = RemoteImageServiceFactory.makeRemoteImageService()
1515
XCTAssertEqual(service.state, .loading)
1616
}
17+
18+
static var allTests = [
19+
("testMakeRemoteImageService", testMakeRemoteImageService)
20+
]
1721
}
1822
#endif

Tests/RemoteImageTests/Services/RemoteImageServiceTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,5 +285,16 @@ final class RemoteImageServiceTests: XCTestCase {
285285
XCTFail("Invalid fetch ph asset cached result")
286286
}
287287
}
288+
289+
static var allTests = [
290+
("testFetchImageURLSuccess", testFetchImageURLSuccess),
291+
("testFetchImageURLFailure", testFetchImageURLFailure),
292+
("testFetchImageURLFailureCompletion", testFetchImageURLFailureCompletion),
293+
("testFetchImageURLCached", testFetchImageURLCached),
294+
("testFetchPHAssetSuccess", testFetchPHAssetSuccess),
295+
("testFetchPHAccessInvalidData", testFetchPHAccessInvalidData),
296+
("testFetchPHAccessFailure", testFetchPHAccessFailure),
297+
("testFetchPHAssetCached", testFetchPHAssetCached)
298+
]
288299
}
289300
#endif

Tests/RemoteImageTests/Views/RemoteImageTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ final class RemoteImageTests: XCTestCase {
3434
XCTFail("\(error)")
3535
}
3636
}
37+
38+
static var allTests = [
39+
("testLoadingState", testLoadingState)
40+
]
3741
}
3842
#endif

Tests/RemoteImageTests/XCTestManifests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ import XCTest
33
#if !canImport(ObjectiveC)
44
public func allTests() -> [XCTestCaseEntry] {
55
return [
6-
testCase(DefaultRemoteImageCacheTests.allTests)
6+
testCase(DefaultRemoteImageCacheTests.allTests),
7+
testCase(PhotoKitServiceErrorTests.allTests),
8+
testCase(PhotoKitServiceTests.allTests),
9+
testCase(RemoteImageTests.allTests),
10+
testCase(RemoteImageServiceDependenciesTests.allTests),
11+
testCase(RemoteImageServiceErrorTests.allTests),
12+
testCase(RemoteImageServiceFactoryTests.allTests),
13+
testCase(RemoteImageServiceTests.allTests),
14+
testCase(RemoteImageStateTests.allTests),
15+
testCase(URLSession_RemoteImageURLDataPublisherTests.allTests)
716
]
817
}
918
#endif

0 commit comments

Comments
 (0)