9
9
*/
10
10
11
11
import XCTest
12
+ import SPMTestSupport
12
13
@testable import PackageRegistry
13
14
14
15
private let defaultRegistryBaseURL = URL ( string: " https://packages.example.com/ " ) !
@@ -47,20 +48,20 @@ final class RegistryConfigurationTests: XCTestCase {
47
48
}
48
49
49
50
func testDecodeEmptyConfiguration( ) throws {
50
- let data = #"""
51
+ let json = #"""
51
52
{
52
53
"registries": {},
53
54
"version": 1
54
55
}
55
- """# . data ( using : . utf8 ) !
56
+ """#
56
57
57
- let configuration = try decoder. decode ( RegistryConfiguration . self, from: data )
58
+ let configuration = try decoder. decode ( RegistryConfiguration . self, from: json )
58
59
XCTAssertNil ( configuration. defaultRegistry)
59
60
XCTAssertEqual ( configuration. scopedRegistries, [ : ] )
60
61
}
61
62
62
63
func testDecodeExampleConfiguration( ) throws {
63
- let data = #"""
64
+ let json = #"""
64
65
{
65
66
"registries": {
66
67
"[default]": {
@@ -75,58 +76,58 @@ final class RegistryConfigurationTests: XCTestCase {
75
76
},
76
77
"version": 1
77
78
}
78
- """# . data ( using : . utf8 ) !
79
+ """#
79
80
80
- let configuration = try decoder. decode ( RegistryConfiguration . self, from: data )
81
+ let configuration = try decoder. decode ( RegistryConfiguration . self, from: json )
81
82
XCTAssertEqual ( configuration. defaultRegistry? . url, defaultRegistryBaseURL)
82
83
XCTAssertEqual ( configuration. scopedRegistries [ " foo " ] ? . url, customRegistryBaseURL)
83
84
XCTAssertEqual ( configuration. scopedRegistries [ " bar " ] ? . url, customRegistryBaseURL)
84
85
}
85
86
86
87
func testDecodeConfigurationWithInvalidRegistryKey( ) throws {
87
- let data = #"""
88
+ let json = #"""
88
89
{
89
90
"registries": {
90
91
0: " \#( customRegistryBaseURL) "
91
92
},
92
93
"version": 1
93
94
}
94
- """# . data ( using : . utf8 ) !
95
+ """#
95
96
96
- XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: data ) )
97
+ XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: json ) )
97
98
}
98
99
99
100
func testDecodeConfigurationWithInvalidRegistryValue( ) throws {
100
- let data = #"""
101
+ let json = #"""
101
102
{
102
103
"registries": {
103
104
"[default]": " \#( customRegistryBaseURL) "
104
105
},
105
106
"version": 1
106
107
}
107
- """# . data ( using : . utf8 ) !
108
+ """#
108
109
109
- XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: data ) )
110
+ XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: json ) )
110
111
}
111
112
112
113
func testDecodeConfigurationWithMissingVersion( ) throws {
113
- let data = #"""
114
+ let json = #"""
114
115
{
115
116
"registries": {}
116
117
}
117
- """# . data ( using : . utf8 ) !
118
+ """#
118
119
119
- XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: data ) )
120
+ XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: json ) )
120
121
}
121
122
122
123
func testDecodeConfigurationWithInvalidVersion( ) throws {
123
- let data = #"""
124
+ let json = #"""
124
125
{
125
126
"registries": {},
126
127
"version": 999
127
128
}
128
- """# . data ( using : . utf8 ) !
129
+ """#
129
130
130
- XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: data ) )
131
+ XCTAssertThrowsError ( try decoder. decode ( RegistryConfiguration . self, from: json ) )
131
132
}
132
133
}
0 commit comments