Skip to content

Commit 07e8a44

Browse files
committed
ContainerRegistry: Add test for empty reference
1 parent 1e30ef9 commit 07e8a44

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Sources/ContainerRegistry/ImageReference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import RegexBuilder
1616

17-
public enum ReferenceError: Error {
17+
public enum ReferenceError: Error, Equatable {
1818
case emptyString
1919
case unexpected(String)
2020
}

Tests/ContainerRegistryTests/ImageReferenceTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,21 @@ struct ReferenceTests {
121121
]
122122

123123
@Test(arguments: tests)
124-
func testReferences(test: ReferenceTestCase) throws {
124+
func testValidReferences(test: ReferenceTestCase) throws {
125125
let parsed = try! ImageReference(fromString: test.reference, defaultRegistry: "default")
126126
#expect(
127127
parsed == test.expected,
128128
"\(String(reflecting: parsed)) is not equal to \(String(reflecting: test.expected))"
129129
)
130130
}
131131

132+
@Test
133+
func testInvalidReferences() throws {
134+
#expect(throws: ReferenceError.emptyString) {
135+
try ImageReference(fromString: "", defaultRegistry: "default")
136+
}
137+
}
138+
132139
@Test
133140
func testLibraryReferences() throws {
134141
// docker.io is a special case, as references such as "swift:slim" with no registry component are translated to "docker.io/library/swift:slim"

0 commit comments

Comments
 (0)