@@ -17,7 +17,7 @@ final class ContainerTests: XCTestCase {
17
17
func testCreateContainers( ) throws {
18
18
let image = try client. images. pullImage ( byName: " hello-world " , tag: " latest " ) . wait ( )
19
19
let container = try client. containers. createContainer ( image: image) . wait ( )
20
-
20
+
21
21
XCTAssertEqual ( container. command, " /hello " )
22
22
}
23
23
@@ -26,7 +26,7 @@ final class ContainerTests: XCTestCase {
26
26
let _ = try client. containers. createContainer ( image: image) . wait ( )
27
27
28
28
let containers = try client. containers. list ( all: true ) . wait ( )
29
-
29
+
30
30
XCTAssert ( containers. count >= 1 )
31
31
}
32
32
@@ -45,32 +45,54 @@ final class ContainerTests: XCTestCase {
45
45
let container = try client. containers. createContainer ( image: image) . wait ( )
46
46
try container. start ( on: client) . wait ( )
47
47
let output = try container. logs ( on: client) . wait ( )
48
-
49
- XCTAssertEqual (
50
- output,
51
- """
52
-
48
+ // Depending on CPU architecture, step 2 of the log output may by:
49
+ // 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
50
+ // (amd64)
51
+ // or
52
+ // 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
53
+ // (arm64v8)
54
+ //
55
+ // Just check the lines before and after this line
56
+ let expectedOutputPrefix = """
57
+
53
58
Hello from Docker!
54
59
This message shows that your installation appears to be working correctly.
55
-
60
+
56
61
To generate this message, Docker took the following steps:
57
62
1. The Docker client contacted the Docker daemon.
58
63
2. The Docker daemon pulled the " hello-world " image from the Docker Hub.
59
- (amd64)
64
+ """
65
+ let expectedOutputSuffix = """
60
66
3. The Docker daemon created a new container from that image which runs the
61
67
executable that produces the output you are currently reading.
62
68
4. The Docker daemon streamed that output to the Docker client, which sent it
63
69
to your terminal.
64
-
70
+
65
71
To try something more ambitious, you can run an Ubuntu container with:
66
72
$ docker run -it ubuntu bash
67
-
73
+
68
74
Share images, automate workflows, and more with a free Docker ID:
69
75
https://hub.docker.com/
70
-
76
+
71
77
For more examples and ideas, visit:
72
78
https://docs.docker.com/get-started/
73
-
79
+
80
+ """
81
+
82
+ XCTAssertTrue (
83
+ output. hasPrefix ( expectedOutputPrefix) ,
84
+ """
85
+ " \( output) "
86
+ did not start with
87
+ " \( expectedOutputPrefix) "
88
+ """
89
+ )
90
+ XCTAssertTrue (
91
+ output. hasSuffix ( expectedOutputSuffix) ,
92
+ """
93
+ " \( output) "
94
+ did not end with
95
+ " \( expectedOutputSuffix) "
74
96
"""
75
97
)
76
98
}
0 commit comments