-
-
Notifications
You must be signed in to change notification settings - Fork 508
/
TargetNodeTests.swift
82 lines (74 loc) · 2.96 KB
/
TargetNodeTests.swift
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
import Basic
import Foundation
import XCTest
import TuistSupportTesting
@testable import TuistCore
final class TargetNodeTests: XCTestCase {
func test_equality() {
// Given
let c1 = TargetNode(project: .test(path: AbsolutePath("/c")),
target: .test(name: "c"),
dependencies: [])
let c2 = TargetNode(project: .test(path: AbsolutePath("/c")),
target: .test(name: "c"),
dependencies: [])
let c3 = TargetNode(project: .test(path: AbsolutePath("/c")),
target: .test(name: "c3"),
dependencies: [])
let d = TargetNode(project: .test(path: AbsolutePath("/d")),
target: .test(name: "c"),
dependencies: [])
// When / Then
XCTAssertEqual(c1, c2)
XCTAssertNotEqual(c2, c3)
XCTAssertNotEqual(c1, d)
XCTAssertEqual(d, d)
}
func test_equality_asGraphNodes() {
// Given
let c1: GraphNode = TargetNode(project: .test(path: AbsolutePath("/c")),
target: .test(name: "c"),
dependencies: [])
let c2: GraphNode = TargetNode(project: .test(path: AbsolutePath("/c")),
target: .test(name: "c"),
dependencies: [])
let c3: GraphNode = TargetNode(project: .test(path: AbsolutePath("/c")),
target: .test(name: "c3"),
dependencies: [])
let d: GraphNode = TargetNode(project: .test(path: AbsolutePath("/d")),
target: .test(name: "c"),
dependencies: [])
// When / Then
XCTAssertEqual(c1, c2)
XCTAssertNotEqual(c2, c3)
XCTAssertNotEqual(c1, d)
}
func test_encode() throws {
// Given
let library = LibraryNode.test()
let framework = FrameworkNode.test()
let cocoapods = CocoaPodsNode.test()
let xcframework = XCFrameworkNode.test()
let node = TargetNode(project: .test(path: AbsolutePath("/")),
target: .test(name: "Target"),
dependencies: [library, framework, cocoapods, xcframework])
let expected = """
{
"type": "source",
"path" : "\(node.path.pathString)",
"bundle_id" : "\(node.target.bundleId)",
"product" : "\(node.target.product.rawValue)",
"name" : "\(node.target.name)",
"dependencies" : [
"\(library.name)",
"\(framework.name)",
"\(cocoapods.name)",
"\(xcframework.name)"
],
"platform" : "\(node.target.platform.rawValue)"
}
"""
// Then
XCTAssertEncodableEqualToJson(node, expected)
}
}