From f598aa2f1024f3f1de9857a73907884081678993 Mon Sep 17 00:00:00 2001 From: Ronit Sabhaya Date: Fri, 9 Jan 2026 20:37:50 -0600 Subject: [PATCH 1/3] Fix: Support x86_64 architecture alias to prevent silent pull failures(#1035) --- .../ContainerAPIService/Client/Arch.swift | 11 ++++ Tests/ContainerAPIClientTests/ArchTests.swift | 64 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 Tests/ContainerAPIClientTests/ArchTests.swift diff --git a/Sources/Services/ContainerAPIService/Client/Arch.swift b/Sources/Services/ContainerAPIService/Client/Arch.swift index 711c0a3a3..70e4f7485 100644 --- a/Sources/Services/ContainerAPIService/Client/Arch.swift +++ b/Sources/Services/ContainerAPIService/Client/Arch.swift @@ -17,6 +17,17 @@ public enum Arch: String { case arm64, amd64 + public init?(rawValue: String) { + switch rawValue.lowercased() { + case "arm64": + self = .arm64 + case "amd64", "x86_64", "x86-64": + self = .amd64 + default: + return nil + } + } + public static func hostArchitecture() -> Arch { #if arch(arm64) return .arm64 diff --git a/Tests/ContainerAPIClientTests/ArchTests.swift b/Tests/ContainerAPIClientTests/ArchTests.swift new file mode 100644 index 000000000..e27aef5df --- /dev/null +++ b/Tests/ContainerAPIClientTests/ArchTests.swift @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// Copyright © 2025-2026 Apple Inc. and the container project authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//===----------------------------------------------------------------------===// + +import XCTest +@testable import ContainerAPIClient + +final class ArchTests: XCTestCase { + + func testAmd64Initialization() throws { + let arch = Arch(rawValue: "amd64") + XCTAssertNotNil(arch) + XCTAssertEqual(arch, .amd64) + } + + func testX86_64Alias() throws { + let arch = Arch(rawValue: "x86_64") + XCTAssertNotNil(arch) + XCTAssertEqual(arch, .amd64) + } + + func testX86_64WithDashAlias() throws { + let arch = Arch(rawValue: "x86-64") + XCTAssertNotNil(arch) + XCTAssertEqual(arch, .amd64) + } + + func testArm64Initialization() throws { + let arch = Arch(rawValue: "arm64") + XCTAssertNotNil(arch) + XCTAssertEqual(arch, .arm64) + } + + func testCaseInsensitive() throws { + XCTAssertEqual(Arch(rawValue: "AMD64"), .amd64) + XCTAssertEqual(Arch(rawValue: "X86_64"), .amd64) + XCTAssertEqual(Arch(rawValue: "ARM64"), .arm64) + XCTAssertEqual(Arch(rawValue: "Amd64"), .amd64) + } + + func testInvalidArchitecture() throws { + XCTAssertNil(Arch(rawValue: "invalid")) + XCTAssertNil(Arch(rawValue: "i386")) + XCTAssertNil(Arch(rawValue: "powerpc")) + XCTAssertNil(Arch(rawValue: "")) + } + + func testRawValueRoundTrip() throws { + XCTAssertEqual(Arch.amd64.rawValue, "amd64") + XCTAssertEqual(Arch.arm64.rawValue, "arm64") + } +} From 57e3e340167f75918848e1df1e0f4b6cdce79135 Mon Sep 17 00:00:00 2001 From: Ronit Sabhaya Date: Sun, 11 Jan 2026 09:43:47 -0600 Subject: [PATCH 2/3] updated the format for tests --- Tests/ContainerAPIClientTests/ArchTests.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tests/ContainerAPIClientTests/ArchTests.swift b/Tests/ContainerAPIClientTests/ArchTests.swift index e27aef5df..aa9efda63 100644 --- a/Tests/ContainerAPIClientTests/ArchTests.swift +++ b/Tests/ContainerAPIClientTests/ArchTests.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,45 +18,45 @@ import XCTest @testable import ContainerAPIClient final class ArchTests: XCTestCase { - + func testAmd64Initialization() throws { let arch = Arch(rawValue: "amd64") XCTAssertNotNil(arch) XCTAssertEqual(arch, .amd64) } - + func testX86_64Alias() throws { let arch = Arch(rawValue: "x86_64") XCTAssertNotNil(arch) XCTAssertEqual(arch, .amd64) } - + func testX86_64WithDashAlias() throws { let arch = Arch(rawValue: "x86-64") XCTAssertNotNil(arch) XCTAssertEqual(arch, .amd64) } - + func testArm64Initialization() throws { let arch = Arch(rawValue: "arm64") XCTAssertNotNil(arch) XCTAssertEqual(arch, .arm64) } - + func testCaseInsensitive() throws { XCTAssertEqual(Arch(rawValue: "AMD64"), .amd64) XCTAssertEqual(Arch(rawValue: "X86_64"), .amd64) XCTAssertEqual(Arch(rawValue: "ARM64"), .arm64) XCTAssertEqual(Arch(rawValue: "Amd64"), .amd64) } - + func testInvalidArchitecture() throws { XCTAssertNil(Arch(rawValue: "invalid")) XCTAssertNil(Arch(rawValue: "i386")) XCTAssertNil(Arch(rawValue: "powerpc")) XCTAssertNil(Arch(rawValue: "")) } - + func testRawValueRoundTrip() throws { XCTAssertEqual(Arch.amd64.rawValue, "amd64") XCTAssertEqual(Arch.arm64.rawValue, "arm64") From dc9d42b16f85cca56de1c07f07ce3aaf05f384de Mon Sep 17 00:00:00 2001 From: Ronit Sabhaya Date: Sun, 11 Jan 2026 20:30:33 -0600 Subject: [PATCH 3/3] refactor the XCtest to testing and refactore the tests --- Tests/ContainerAPIClientTests/ArchTests.swift | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/Tests/ContainerAPIClientTests/ArchTests.swift b/Tests/ContainerAPIClientTests/ArchTests.swift index aa9efda63..108a038ea 100644 --- a/Tests/ContainerAPIClientTests/ArchTests.swift +++ b/Tests/ContainerAPIClientTests/ArchTests.swift @@ -14,51 +14,52 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import XCTest +import Testing + @testable import ContainerAPIClient -final class ArchTests: XCTestCase { +struct ArchTests { - func testAmd64Initialization() throws { + @Test func testAmd64Initialization() throws { let arch = Arch(rawValue: "amd64") - XCTAssertNotNil(arch) - XCTAssertEqual(arch, .amd64) + #expect(arch != nil) + #expect(arch == .amd64) } - func testX86_64Alias() throws { + @Test func testX86_64Alias() throws { let arch = Arch(rawValue: "x86_64") - XCTAssertNotNil(arch) - XCTAssertEqual(arch, .amd64) + #expect(arch != nil) + #expect(arch == .amd64) } - func testX86_64WithDashAlias() throws { + @Test func testX86_64WithDashAlias() throws { let arch = Arch(rawValue: "x86-64") - XCTAssertNotNil(arch) - XCTAssertEqual(arch, .amd64) + #expect(arch != nil) + #expect(arch == .amd64) } - func testArm64Initialization() throws { + @Test func testArm64Initialization() throws { let arch = Arch(rawValue: "arm64") - XCTAssertNotNil(arch) - XCTAssertEqual(arch, .arm64) + #expect(arch != nil) + #expect(arch == .arm64) } - func testCaseInsensitive() throws { - XCTAssertEqual(Arch(rawValue: "AMD64"), .amd64) - XCTAssertEqual(Arch(rawValue: "X86_64"), .amd64) - XCTAssertEqual(Arch(rawValue: "ARM64"), .arm64) - XCTAssertEqual(Arch(rawValue: "Amd64"), .amd64) + @Test func testCaseInsensitive() throws { + #expect(Arch(rawValue: "AMD64") == .amd64) + #expect(Arch(rawValue: "X86_64") == .amd64) + #expect(Arch(rawValue: "ARM64") == .arm64) + #expect(Arch(rawValue: "Amd64") == .amd64) } - func testInvalidArchitecture() throws { - XCTAssertNil(Arch(rawValue: "invalid")) - XCTAssertNil(Arch(rawValue: "i386")) - XCTAssertNil(Arch(rawValue: "powerpc")) - XCTAssertNil(Arch(rawValue: "")) + @Test func testInvalidArchitecture() throws { + #expect(Arch(rawValue: "invalid") == nil) + #expect(Arch(rawValue: "i386") == nil) + #expect(Arch(rawValue: "powerpc") == nil) + #expect(Arch(rawValue: "") == nil) } - func testRawValueRoundTrip() throws { - XCTAssertEqual(Arch.amd64.rawValue, "amd64") - XCTAssertEqual(Arch.arm64.rawValue, "arm64") + @Test func testRawValueRoundTrip() throws { + #expect(Arch.amd64.rawValue == "amd64") + #expect(Arch.arm64.rawValue == "arm64") } }