@@ -5,122 +5,124 @@ vi.mock("fs", () => ({ existsSync: mockExistsSync }));
55const mockReadFile = vi . fn ( ) ;
66vi . mock ( "fs/promises" , ( ) => ( { readFile : mockReadFile } ) ) ;
77
8- let getContainerRuntimeConfig : GetContainerRuntimeConfig ;
8+ describe . sequential ( "Config" , ( ) => {
9+ let getContainerRuntimeConfig : GetContainerRuntimeConfig ;
910
10- beforeEach ( async ( ) => {
11- getContainerRuntimeConfig = ( await import ( "./config" ) ) . getContainerRuntimeConfig ;
12- } ) ;
13-
14- afterEach ( ( ) => {
15- vi . resetModules ( ) ;
16- } ) ;
17-
18- test ( "should not set anything" , async ( ) => {
19- const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
20-
21- expect ( dockerClientConfig . dockerHost ) . toBeUndefined ( ) ;
22- expect ( dockerClientConfig . dockerTlsVerify ) . toBeUndefined ( ) ;
23- expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
24- } ) ;
11+ beforeEach ( async ( ) => {
12+ getContainerRuntimeConfig = ( await import ( "./config" ) ) . getContainerRuntimeConfig ;
13+ } ) ;
2514
26- describe ( "environment" , ( ) => {
27- beforeEach ( ( ) => {
28- mockExistsSync . mockReturnValue ( false ) ;
15+ afterEach ( ( ) => {
16+ vi . resetModules ( ) ;
2917 } ) ;
3018
31- test ( "should set the host" , async ( ) => {
32- const dockerClientConfig = await getContainerRuntimeConfig ( {
33- DOCKER_HOST : "tcp://my.docker.host:1234" ,
34- } ) ;
19+ it ( "should not set anything" , async ( ) => {
20+ const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
3521
36- expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
22+ expect ( dockerClientConfig . dockerHost ) . toBeUndefined ( ) ;
3723 expect ( dockerClientConfig . dockerTlsVerify ) . toBeUndefined ( ) ;
3824 expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
3925 } ) ;
4026
41- test ( "should set TLS verify" , async ( ) => {
42- const dockerClientConfig = await getContainerRuntimeConfig ( {
43- DOCKER_HOST : "tcp://my.docker.host:1234" ,
44- DOCKER_TLS_VERIFY : "1" ,
27+ describe ( "environment" , ( ) => {
28+ beforeEach ( ( ) => {
29+ mockExistsSync . mockReturnValue ( false ) ;
4530 } ) ;
4631
47- expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker. host:1234" ) ;
48- expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
49- expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
50- } ) ;
32+ it ( "should set the host" , async ( ) => {
33+ const dockerClientConfig = await getContainerRuntimeConfig ( {
34+ DOCKER_HOST : "tcp://my.docker.host:1234" ,
35+ } ) ;
5136
52- test ( "should set the cert path" , async ( ) => {
53- const dockerClientConfig = await getContainerRuntimeConfig ( {
54- DOCKER_HOST : "tcp://my.docker.host:1234" ,
55- DOCKER_TLS_VERIFY : "1" ,
56- DOCKER_CERT_PATH : "/some/path" ,
37+ expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
38+ expect ( dockerClientConfig . dockerTlsVerify ) . toBeUndefined ( ) ;
39+ expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
5740 } ) ;
5841
59- expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
60- expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
61- expect ( dockerClientConfig . dockerCertPath ) . toBe ( "/some/path" ) ;
62- } ) ;
63- } ) ;
42+ it ( "should set TLS verify" , async ( ) => {
43+ const dockerClientConfig = await getContainerRuntimeConfig ( {
44+ DOCKER_HOST : "tcp://my.docker.host:1234" ,
45+ DOCKER_TLS_VERIFY : "1" ,
46+ } ) ;
6447
65- describe ( "testcontainers.properties file" , ( ) => {
66- beforeEach ( ( ) => {
67- mockExistsSync . mockReturnValue ( true ) ;
48+ expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
49+ expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
50+ expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
51+ } ) ;
52+
53+ it ( "should set the cert path" , async ( ) => {
54+ const dockerClientConfig = await getContainerRuntimeConfig ( {
55+ DOCKER_HOST : "tcp://my.docker.host:1234" ,
56+ DOCKER_TLS_VERIFY : "1" ,
57+ DOCKER_CERT_PATH : "/some/path" ,
58+ } ) ;
59+
60+ expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
61+ expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
62+ expect ( dockerClientConfig . dockerCertPath ) . toBe ( "/some/path" ) ;
63+ } ) ;
6864 } ) ;
6965
70- test ( "should set the tc host" , async ( ) => {
71- mockReadFile . mockResolvedValueOnce ( "tc.host=tcp://my.docker.host:1234" ) ;
66+ describe ( "testcontainers.properties file" , ( ) => {
67+ beforeEach ( ( ) => {
68+ mockExistsSync . mockReturnValue ( true ) ;
69+ } ) ;
7270
73- const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
71+ it ( "should set the tc host" , async ( ) => {
72+ mockReadFile . mockResolvedValueOnce ( "tc.host=tcp://my.docker.host:1234" ) ;
7473
75- expect ( dockerClientConfig . tcHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
76- } ) ;
74+ const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
7775
78- test ( "should set the host" , async ( ) => {
79- mockReadFile . mockResolvedValueOnce ( "docker.host=tcp://my.docker.host:1234" ) ;
76+ expect ( dockerClientConfig . tcHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
77+ } ) ;
8078
81- const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
79+ it ( "should set the host" , async ( ) => {
80+ mockReadFile . mockResolvedValueOnce ( "docker.host=tcp://my.docker.host:1234" ) ;
8281
83- expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
84- expect ( dockerClientConfig . dockerTlsVerify ) . toBeUndefined ( ) ;
85- expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
86- } ) ;
82+ const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
83+
84+ expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
85+ expect ( dockerClientConfig . dockerTlsVerify ) . toBeUndefined ( ) ;
86+ expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
87+ } ) ;
8788
88- test ( "should set TLS verify" , async ( ) => {
89- mockReadFile . mockResolvedValueOnce ( `
89+ it ( "should set TLS verify" , async ( ) => {
90+ mockReadFile . mockResolvedValueOnce ( `
9091 docker.host=tcp://my.docker.host:1234
9192 docker.tls.verify=1
9293 ` ) ;
9394
94- const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
95+ const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
9596
96- expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
97- expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
98- expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
99- } ) ;
97+ expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
98+ expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
99+ expect ( dockerClientConfig . dockerCertPath ) . toBeUndefined ( ) ;
100+ } ) ;
100101
101- test ( "should set the cert path" , async ( ) => {
102- mockReadFile . mockResolvedValueOnce ( `
102+ it ( "should set the cert path" , async ( ) => {
103+ mockReadFile . mockResolvedValueOnce ( `
103104 docker.host=tcp://my.docker.host:1234
104105 docker.tls.verify=1
105106 docker.cert.path=/some/path
106107 ` ) ;
107108
108- const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
109+ const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
109110
110- expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
111- expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
112- expect ( dockerClientConfig . dockerCertPath ) . toBe ( "/some/path" ) ;
111+ expect ( dockerClientConfig . dockerHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
112+ expect ( dockerClientConfig . dockerTlsVerify ) . toBe ( "1" ) ;
113+ expect ( dockerClientConfig . dockerCertPath ) . toBe ( "/some/path" ) ;
114+ } ) ;
113115 } ) ;
114- } ) ;
115116
116- test ( "should cache the result" , async ( ) => {
117- mockExistsSync . mockReturnValue ( true ) ;
118- mockReadFile . mockResolvedValueOnce ( "tc.host=tcp://my.docker.host:1234" ) ;
117+ it ( "should cache the result" , async ( ) => {
118+ mockExistsSync . mockReturnValue ( true ) ;
119+ mockReadFile . mockResolvedValueOnce ( "tc.host=tcp://my.docker.host:1234" ) ;
119120
120- await getContainerRuntimeConfig ( { } ) ;
121- const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
121+ await getContainerRuntimeConfig ( { } ) ;
122+ const dockerClientConfig = await getContainerRuntimeConfig ( { } ) ;
122123
123- expect ( dockerClientConfig . tcHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
124- expect ( mockExistsSync ) . toHaveBeenCalledTimes ( 1 ) ;
125- expect ( mockReadFile ) . toHaveBeenCalledTimes ( 1 ) ;
124+ expect ( dockerClientConfig . tcHost ) . toBe ( "tcp://my.docker.host:1234" ) ;
125+ expect ( mockExistsSync ) . toHaveBeenCalledTimes ( 1 ) ;
126+ expect ( mockReadFile ) . toHaveBeenCalledTimes ( 1 ) ;
127+ } ) ;
126128} ) ;
0 commit comments