1414// limitations under the License.
1515//===----------------------------------------------------------------------===//
1616
17- import  XCTest 
18- import  ContainerCompose 
17+ import  Testing 
18+ import  ComposeCore 
1919import  ContainerizationError
20- @testable   import  ContainerCompose
20+ import  Logging
21+ import  Foundation
22+ @testable   import  ComposeCore
2123
22- final  class  HealthCheckTests :  XCTestCase  { 
23-     func  testHealthCheckParsing( )  throws  { 
24+ struct  HealthCheckTests  { 
25+     let  log   =  Logger ( label:  " test " ) 
26+     @Test   func  testHealthCheckParsing( )  throws  { 
2427        let  yaml  =  """ 
2528        version: '3' 
2629        services: 
@@ -34,20 +37,20 @@ final class HealthCheckTests: XCTestCase {
3437              start_period: 40s 
3538         """ 
3639
37-         let  parser  =  ComposeParser ( log:  . test ) 
40+         let  parser  =  ComposeParser ( log:  log ) 
3841        let  composeFile  =  try   parser. parse ( from:  yaml. data ( using:  . utf8) !) 
3942
40-         XCTAssertNotNil ( composeFile. services [ " web " ] ? . healthcheck) 
43+         #expect ( composeFile. services [ " web " ] ? . healthcheck  !=   nil ) 
4144        let  healthcheck  =  composeFile. services [ " web " ] !. healthcheck!
4245
43-         XCTAssertEqual ( healthcheck. test,  . list( [ " CMD " ,  " curl " ,  " -f " ,  " http://localhost " ] ) ) 
44-         XCTAssertEqual ( healthcheck. interval,  " 30s " ) 
45-         XCTAssertEqual ( healthcheck. timeout,  " 10s " ) 
46-         XCTAssertEqual ( healthcheck. retries,  3 ) 
47-         XCTAssertEqual ( healthcheck. startPeriod,  " 40s " ) 
46+         #expect ( healthcheck. test  ==  . list( [ " CMD " ,  " curl " ,  " -f " ,  " http://localhost " ] ) ) 
47+         #expect ( healthcheck. interval  ==  " 30s " ) 
48+         #expect ( healthcheck. timeout  ==  " 10s " ) 
49+         #expect ( healthcheck. retries  ==  3 ) 
50+         #expect ( healthcheck. startPeriod  ==  " 40s " ) 
4851    } 
4952
50-     func  testHealthCheckStringFormat( )  throws  { 
53+     @ Test   func  testHealthCheckStringFormat( )  throws  { 
5154        let  yaml  =  """ 
5255        version: '3' 
5356        services: 
@@ -57,14 +60,14 @@ final class HealthCheckTests: XCTestCase {
5760              test:  " curl -f http://localhost || exit 1 " 
5861         """ 
5962
60-         let  parser  =  ComposeParser ( log:  . test ) 
63+         let  parser  =  ComposeParser ( log:  log ) 
6164        let  composeFile  =  try   parser. parse ( from:  yaml. data ( using:  . utf8) !) 
6265
6366        let  healthcheck  =  composeFile. services [ " app " ] !. healthcheck!
64-         XCTAssertEqual ( healthcheck. test,  . string( " curl -f http://localhost || exit 1 " ) ) 
67+         #expect ( healthcheck. test  ==  . string( " curl -f http://localhost || exit 1 " ) ) 
6568    } 
6669
67-     func  testHealthCheckDisabled( )  throws  { 
70+     @ Test   func  testHealthCheckDisabled( )  throws  { 
6871        let  yaml  =  """ 
6972        version: '3' 
7073        services: 
@@ -74,14 +77,14 @@ final class HealthCheckTests: XCTestCase {
7477              disable: true 
7578         """ 
7679
77-         let  parser  =  ComposeParser ( log:  . test ) 
80+         let  parser  =  ComposeParser ( log:  log ) 
7881        let  composeFile  =  try   parser. parse ( from:  yaml. data ( using:  . utf8) !) 
7982
8083        let  healthcheck  =  composeFile. services [ " db " ] !. healthcheck!
81-         XCTAssertTrue ( healthcheck. disable ??  false ) 
84+         #expect ( healthcheck. disable ??  false ) 
8285    } 
8386
84-     func  testProjectConverterHealthCheck( )  throws  { 
87+     @ Test   func  testProjectConverterHealthCheck( )  throws  { 
8588        let  yaml  =  """ 
8689        version: '3' 
8790        services: 
@@ -95,28 +98,27 @@ final class HealthCheckTests: XCTestCase {
9598              start_period: 10s 
9699         """ 
97100
98-         let  parser  =  ComposeParser ( log:  . test ) 
101+         let  parser  =  ComposeParser ( log:  log ) 
99102        let  composeFile  =  try   parser. parse ( from:  yaml. data ( using:  . utf8) !) 
100103
101-         let  converter  =  ProjectConverter ( log:  . test ) 
104+         let  converter  =  ProjectConverter ( log:  log ) 
102105        let  project  =  try   converter. convert ( 
103106            composeFile:  composeFile, 
104-             projectName:  " test " , 
105-             workingDirectory:  URL ( fileURLWithPath:  " /tmp " ) 
107+             projectName:  " test " 
106108        ) 
107109
108110        let  service  =  project. services [ " web " ] !
109-         XCTAssertNotNil ( service. healthCheck) 
111+         #expect ( service. healthCheck  !=   nil ) 
110112
111113        let  healthCheck  =  service. healthCheck!
112-         XCTAssertEqual ( healthCheck. test,  [ " CMD " ,  " wget " ,  " -q " ,  " --spider " ,  " http://localhost " ] ) 
113-         XCTAssertEqual ( healthCheck. interval,  30 ) 
114-         XCTAssertEqual ( healthCheck. timeout,  5 ) 
115-         XCTAssertEqual ( healthCheck. retries,  3 ) 
116-         XCTAssertEqual ( healthCheck. startPeriod,  10 ) 
114+         #expect ( healthCheck. test  ==  [ " CMD " ,  " wget " ,  " -q " ,  " --spider " ,  " http://localhost " ] ) 
115+         #expect ( healthCheck. interval  ==  30 ) 
116+         #expect ( healthCheck. timeout  ==  5 ) 
117+         #expect ( healthCheck. retries  ==  3 ) 
118+         #expect ( healthCheck. startPeriod  ==  10 ) 
117119    } 
118120
119-     func  testHealthCheckWithShellFormat( )  throws  { 
121+     @ Test   func  testHealthCheckWithShellFormat( )  throws  { 
120122        let  yaml  =  """ 
121123        version: '3' 
122124        services: 
@@ -127,22 +129,21 @@ final class HealthCheckTests: XCTestCase {
127129              interval: 10s 
128130         """ 
129131
130-         let  parser  =  ComposeParser ( log:  . test ) 
132+         let  parser  =  ComposeParser ( log:  log ) 
131133        let  composeFile  =  try   parser. parse ( from:  yaml. data ( using:  . utf8) !) 
132134
133-         let  converter  =  ProjectConverter ( log:  . test ) 
135+         let  converter  =  ProjectConverter ( log:  log ) 
134136        let  project  =  try   converter. convert ( 
135137            composeFile:  composeFile, 
136-             projectName:  " test " , 
137-             workingDirectory:  URL ( fileURLWithPath:  " /tmp " ) 
138+             projectName:  " test " 
138139        ) 
139140
140141        let  healthCheck  =  project. services [ " api " ] !. healthCheck!
141142        // CMD-SHELL should be converted to shell command
142-         XCTAssertEqual ( healthCheck. test,  [ " /bin/sh " ,  " -c " ,  " curl -f http://localhost:3000/health || exit 1 " ] ) 
143+         #expect ( healthCheck. test  ==  [ " /bin/sh " ,  " -c " ,  " curl -f http://localhost:3000/health || exit 1 " ] ) 
143144    } 
144145
145-     func  testHealthCheckNoneDisabled( )  throws  { 
146+     @ Test   func  testHealthCheckNoneDisabled( )  throws  { 
146147        let  yaml  =  """ 
147148        version: '3' 
148149        services: 
@@ -152,17 +153,16 @@ final class HealthCheckTests: XCTestCase {
152153              test: [ " NONE " ] 
153154         """ 
154155
155-         let  parser  =  ComposeParser ( log:  . test ) 
156+         let  parser  =  ComposeParser ( log:  log ) 
156157        let  composeFile  =  try   parser. parse ( from:  yaml. data ( using:  . utf8) !) 
157158
158-         let  converter  =  ProjectConverter ( log:  . test ) 
159+         let  converter  =  ProjectConverter ( log:  log ) 
159160        let  project  =  try   converter. convert ( 
160161            composeFile:  composeFile, 
161-             projectName:  " test " , 
162-             workingDirectory:  URL ( fileURLWithPath:  " /tmp " ) 
162+             projectName:  " test " 
163163        ) 
164164
165165        // NONE should result in no health check
166-         XCTAssertNil ( project. services [ " worker " ] !. healthCheck) 
166+         #expect ( project. services [ " worker " ] !. healthCheck  ==   nil ) 
167167    } 
168168} 
0 commit comments