-
Notifications
You must be signed in to change notification settings - Fork 491
Expand file tree
/
Copy pathCoreDataFeedStoreTests.swift
More file actions
89 lines (72 loc) · 2.3 KB
/
CoreDataFeedStoreTests.swift
File metadata and controls
89 lines (72 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Copyright © Essential Developer. All rights reserved.
//
import XCTest
import EssentialFeed
@MainActor
class CoreDataFeedStoreTests: XCTestCase, FeedStoreSpecs {
func test_retrieve_deliversEmptyOnEmptyCache() async throws {
try await makeSUT { sut in
assertThatRetrieveDeliversEmptyOnEmptyCache(on: sut)
}
}
func test_retrieve_hasNoSideEffectsOnEmptyCache() async throws {
try await makeSUT { sut in
assertThatRetrieveHasNoSideEffectsOnEmptyCache(on: sut)
}
}
func test_retrieve_deliversFoundValuesOnNonEmptyCache() async throws {
try await makeSUT { sut in
assertThatRetrieveDeliversFoundValuesOnNonEmptyCache(on: sut)
}
}
func test_retrieve_hasNoSideEffectsOnNonEmptyCache() async throws {
try await makeSUT { sut in
assertThatRetrieveHasNoSideEffectsOnNonEmptyCache(on: sut)
}
}
func test_insert_deliversNoErrorOnEmptyCache() async throws {
try await makeSUT { sut in
assertThatInsertDeliversNoErrorOnEmptyCache(on: sut)
}
}
func test_insert_deliversNoErrorOnNonEmptyCache() async throws {
try await makeSUT { sut in
assertThatInsertDeliversNoErrorOnNonEmptyCache(on: sut)
}
}
func test_insert_overridesPreviouslyInsertedCacheValues() async throws {
try await makeSUT { sut in
assertThatInsertOverridesPreviouslyInsertedCacheValues(on: sut)
}
}
func test_delete_deliversNoErrorOnEmptyCache() async throws {
try await makeSUT { sut in
assertThatDeleteDeliversNoErrorOnEmptyCache(on: sut)
}
}
func test_delete_hasNoSideEffectsOnEmptyCache() async throws {
try await makeSUT { sut in
assertThatDeleteHasNoSideEffectsOnEmptyCache(on: sut)
}
}
func test_delete_deliversNoErrorOnNonEmptyCache() async throws {
try await makeSUT { sut in
assertThatDeleteDeliversNoErrorOnNonEmptyCache(on: sut)
}
}
func test_delete_emptiesPreviouslyInsertedCache() async throws {
try await makeSUT { sut in
assertThatDeleteEmptiesPreviouslyInsertedCache(on: sut)
}
}
// - MARK: Helpers
private func makeSUT(_ test: @Sendable @escaping (CoreDataFeedStore) -> Void, file: StaticString = #filePath, line: UInt = #line) async throws {
let storeURL = URL(fileURLWithPath: "/dev/null")
let sut = try CoreDataFeedStore(storeURL: storeURL)
trackForMemoryLeaks(sut, file: file, line: line)
await sut.perform {
test(sut)
}
}
}