@@ -13,24 +13,22 @@ import (
1313 "github.com/testcontainers/testcontainers-go/wait"
1414)
1515
16+ const testBashImage string = "bash:5.2.26"
17+
1618func TestCopyFileToContainer (t * testing.T ) {
1719 ctx , cnl := context .WithTimeout (context .Background (), 30 * time .Second )
1820 defer cnl ()
1921
2022 // copyFileOnCreate {
2123 absPath , err := filepath .Abs (filepath .Join ("." , "testdata" , "hello.sh" ))
22- if err != nil {
23- t .Fatal (err )
24- }
24+ require .NoError (t , err )
2525
2626 r , err := os .Open (absPath )
27- if err != nil {
28- t .Fatal (err )
29- }
27+ require .NoError (t , err )
3028
3129 ctr , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
3230 ContainerRequest : testcontainers.ContainerRequest {
33- Image : "docker.io/bash" ,
31+ Image : testBashImage ,
3432 Files : []testcontainers.ContainerFile {
3533 {
3634 Reader : r ,
@@ -56,17 +54,13 @@ func TestCopyFileToRunningContainer(t *testing.T) {
5654 // Not using the assertations here to avoid leaking the library into the example
5755 // copyFileAfterCreate {
5856 waitForPath , err := filepath .Abs (filepath .Join ("." , "testdata" , "waitForHello.sh" ))
59- if err != nil {
60- t .Fatal (err )
61- }
57+ require .NoError (t , err )
6258 helloPath , err := filepath .Abs (filepath .Join ("." , "testdata" , "hello.sh" ))
63- if err != nil {
64- t .Fatal (err )
65- }
59+ require .NoError (t , err )
6660
6761 ctr , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
6862 ContainerRequest : testcontainers.ContainerRequest {
69- Image : "docker.io/bash:5.2.26" ,
63+ Image : testBashImage ,
7064 Files : []testcontainers.ContainerFile {
7165 {
7266 HostFilePath : waitForPath ,
@@ -98,13 +92,11 @@ func TestCopyDirectoryToContainer(t *testing.T) {
9892 // Not using the assertations here to avoid leaking the library into the example
9993 // copyDirectoryToContainer {
10094 dataDirectory , err := filepath .Abs (filepath .Join ("." , "testdata" ))
101- if err != nil {
102- t .Fatal (err )
103- }
95+ require .NoError (t , err )
10496
10597 ctr , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
10698 ContainerRequest : testcontainers.ContainerRequest {
107- Image : "docker.io/bash" ,
99+ Image : testBashImage ,
108100 Files : []testcontainers.ContainerFile {
109101 {
110102 HostFilePath : dataDirectory ,
@@ -131,17 +123,13 @@ func TestCopyDirectoryToRunningContainerAsFile(t *testing.T) {
131123
132124 // copyDirectoryToRunningContainerAsFile {
133125 dataDirectory , err := filepath .Abs (filepath .Join ("." , "testdata" ))
134- if err != nil {
135- t .Fatal (err )
136- }
126+ require .NoError (t , err )
137127 waitForPath , err := filepath .Abs (filepath .Join (dataDirectory , "waitForHello.sh" ))
138- if err != nil {
139- t .Fatal (err )
140- }
128+ require .NoError (t , err )
141129
142130 ctr , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
143131 ContainerRequest : testcontainers.ContainerRequest {
144- Image : "docker.io/bash" ,
132+ Image : testBashImage ,
145133 Files : []testcontainers.ContainerFile {
146134 {
147135 HostFilePath : waitForPath ,
@@ -173,17 +161,13 @@ func TestCopyDirectoryToRunningContainerAsDir(t *testing.T) {
173161 // Not using the assertations here to avoid leaking the library into the example
174162 // copyDirectoryToRunningContainerAsDir {
175163 waitForPath , err := filepath .Abs (filepath .Join ("." , "testdata" , "waitForHello.sh" ))
176- if err != nil {
177- t .Fatal (err )
178- }
164+ require .NoError (t , err )
179165 dataDirectory , err := filepath .Abs (filepath .Join ("." , "testdata" ))
180- if err != nil {
181- t .Fatal (err )
182- }
166+ require .NoError (t , err )
183167
184168 ctr , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
185169 ContainerRequest : testcontainers.ContainerRequest {
186- Image : "docker.io/bash" ,
170+ Image : testBashImage ,
187171 Files : []testcontainers.ContainerFile {
188172 {
189173 HostFilePath : waitForPath ,
0 commit comments