Skip to content

Commit cb82b1c

Browse files
committed
Fixed the TestCLIVersion failing test
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
1 parent 0e9399d commit cb82b1c

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

Tests/CLITests/Subcommands/System/TestCLIVersion.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ final class TestCLIVersion: CLITest {
5555
.components(separatedBy: .newlines)
5656
#expect(lines.count >= 2) // header + at least CLI row
5757
#expect(lines[0].contains("COMPONENT") && lines[0].contains("VERSION") && lines[0].contains("BUILD") && lines[0].contains("COMMIT"))
58-
#expect(lines[1].hasPrefix("CLI "))
58+
#expect(lines[1].hasPrefix("container"))
5959

6060
// Build should reflect the binary we are running (debug/release)
6161
let expected = try expectedBuildType()
62-
#expect(lines.joined(separator: "\n").contains(" CLI "))
6362
#expect(lines.joined(separator: "\n").contains(" \(expected) "))
6463
_ = data // silence unused warning if assertions short-circuit
6564
}
@@ -69,13 +68,13 @@ final class TestCLIVersion: CLITest {
6968
#expect(status == 0, "system version --format json should succeed, stderr: \(err)")
7069
#expect(!out.isEmpty)
7170

72-
let decoded = try JSONDecoder().decode(VersionJSON.self, from: data)
73-
#expect(decoded.appName == "container CLI")
74-
#expect(!decoded.version.isEmpty)
75-
#expect(!decoded.commit.isEmpty)
71+
let decoded = try JSONDecoder().decode([VersionJSON].self, from: data)
72+
#expect(decoded[0].appName == "container")
73+
#expect(!decoded[0].version.isEmpty)
74+
#expect(!decoded[0].commit.isEmpty)
7675

7776
let expected = try expectedBuildType()
78-
#expect(decoded.buildType == expected)
77+
#expect(decoded[0].buildType == expected)
7978
}
8079

8180
@Test func explicitTableFormat() throws {
@@ -87,16 +86,15 @@ final class TestCLIVersion: CLITest {
8786
.components(separatedBy: .newlines)
8887
#expect(lines.count >= 2)
8988
#expect(lines[0].contains("COMPONENT") && lines[0].contains("VERSION") && lines[0].contains("BUILD") && lines[0].contains("COMMIT"))
90-
#expect(lines[1].hasPrefix("CLI "))
9189
}
9290

9391
@Test func buildTypeMatchesBinary() throws {
9492
// Validate build type via JSON to avoid parsing table text loosely
9593
let (data, _, err, status) = try run(arguments: ["system", "version", "--format", "json"])
9694
#expect(status == 0, "version --format json should succeed, stderr: \(err)")
97-
let decoded = try JSONDecoder().decode(VersionJSON.self, from: data)
95+
let decoded = try JSONDecoder().decode([VersionJSON].self, from: data)
9896

9997
let expected = try expectedBuildType()
100-
#expect(decoded.buildType == expected, "Expected build type \(expected) but got \(decoded.buildType)")
98+
#expect(decoded[0].buildType == expected, "Expected build type \(expected) but got \(decoded[0].buildType)")
10199
}
102100
}

0 commit comments

Comments
 (0)