mirror of
https://github.com/apple/container.git
synced 2026-09-24 16:45:39 +00:00
Ensure test filenames match test suite names and each file has a single suite defined (#1877)
This PR cleans up some of the new IntegrationTests files to ensure that each file has a single test suite defined within it and the name of the file matches the name of the test suite. Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
This commit is contained in:
@@ -90,58 +90,3 @@ struct TestCLIRemove {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Serial removal tests that use `delete --all` and affect global container state.
|
||||
@Suite(.serialized)
|
||||
struct TestCLIRemoveSerial {
|
||||
@Test func testDeleteAllStopped() async throws {
|
||||
try await ContainerFixture.with { f in
|
||||
let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0])
|
||||
let name1 = "\(f.testID)-c1"
|
||||
let name2 = "\(f.testID)-c2"
|
||||
try f.doCreate(name: name1, image: image)
|
||||
f.addCleanup { try f.doRemoveIfExists(name1, ignoreFailure: true) }
|
||||
try f.doCreate(name: name2, image: image)
|
||||
f.addCleanup { try f.doRemoveIfExists(name2, ignoreFailure: true) }
|
||||
|
||||
try f.run(["delete", "--all"]).check()
|
||||
|
||||
#expect(try f.run(["inspect", name1]).status != 0, "name1 should be deleted")
|
||||
#expect(try f.run(["inspect", name2]).status != 0, "name2 should be deleted")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func testDeleteAllSkipsRunning() async throws {
|
||||
try await ContainerFixture.with { f in
|
||||
let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0])
|
||||
let runningName = "\(f.testID)-running"
|
||||
let stoppedName = "\(f.testID)-stopped"
|
||||
|
||||
try f.doLongRun(name: runningName, image: image, autoRemove: false)
|
||||
f.addCleanup {
|
||||
try? f.doStop(runningName)
|
||||
try? f.doRemove(runningName)
|
||||
}
|
||||
try f.doCreate(name: stoppedName, image: image)
|
||||
f.addCleanup { try f.doRemoveIfExists(stoppedName, ignoreFailure: true) }
|
||||
|
||||
try f.run(["delete", "--all"]).check()
|
||||
|
||||
#expect(try f.getContainerStatus(runningName) == "running", "running container should survive delete --all")
|
||||
#expect(try f.run(["inspect", stoppedName]).status != 0, "stopped container should be deleted")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func testDeleteAllForce() async throws {
|
||||
try await ContainerFixture.with { f in
|
||||
let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0])
|
||||
let name = "\(f.testID)-c"
|
||||
try f.doLongRun(name: name, image: image, autoRemove: false)
|
||||
f.addCleanup { try f.doRemoveIfExists(name, force: true, ignoreFailure: true) }
|
||||
|
||||
try f.run(["delete", "--all", "--force"]).check()
|
||||
|
||||
#expect(try f.run(["inspect", name]).status != 0, "container should be deleted by --force")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// 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.
|
||||
// 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 Foundation
|
||||
import Testing
|
||||
|
||||
/// Serial removal tests that use `delete --all` and affect global container state.
|
||||
@Suite(.serialized)
|
||||
struct TestCLIRemoveSerial {
|
||||
@Test func testDeleteAllStopped() async throws {
|
||||
try await ContainerFixture.with { f in
|
||||
let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0])
|
||||
let name1 = "\(f.testID)-c1"
|
||||
let name2 = "\(f.testID)-c2"
|
||||
try f.doCreate(name: name1, image: image)
|
||||
f.addCleanup { try f.doRemoveIfExists(name1, ignoreFailure: true) }
|
||||
try f.doCreate(name: name2, image: image)
|
||||
f.addCleanup { try f.doRemoveIfExists(name2, ignoreFailure: true) }
|
||||
|
||||
try f.run(["delete", "--all"]).check()
|
||||
|
||||
#expect(try f.run(["inspect", name1]).status != 0, "name1 should be deleted")
|
||||
#expect(try f.run(["inspect", name2]).status != 0, "name2 should be deleted")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func testDeleteAllSkipsRunning() async throws {
|
||||
try await ContainerFixture.with { f in
|
||||
let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0])
|
||||
let runningName = "\(f.testID)-running"
|
||||
let stoppedName = "\(f.testID)-stopped"
|
||||
|
||||
try f.doLongRun(name: runningName, image: image, autoRemove: false)
|
||||
f.addCleanup {
|
||||
try? f.doStop(runningName)
|
||||
try? f.doRemove(runningName)
|
||||
}
|
||||
try f.doCreate(name: stoppedName, image: image)
|
||||
f.addCleanup { try f.doRemoveIfExists(stoppedName, ignoreFailure: true) }
|
||||
|
||||
try f.run(["delete", "--all"]).check()
|
||||
|
||||
#expect(try f.getContainerStatus(runningName) == "running", "running container should survive delete --all")
|
||||
#expect(try f.run(["inspect", stoppedName]).status != 0, "stopped container should be deleted")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func testDeleteAllForce() async throws {
|
||||
try await ContainerFixture.with { f in
|
||||
let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0])
|
||||
let name = "\(f.testID)-c"
|
||||
try f.doLongRun(name: name, image: image, autoRemove: false)
|
||||
f.addCleanup { try f.doRemoveIfExists(name, force: true, ignoreFailure: true) }
|
||||
|
||||
try f.run(["delete", "--all", "--force"]).check()
|
||||
|
||||
#expect(try f.run(["inspect", name]).status != 0, "container should be deleted by --force")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user