@@ -102,7 +102,7 @@ func TestDockerImageAuth(t *testing.T) {
102102 username , password := "gopher" , "secret"
103103 creds := setAuthConfig (t , exampleAuth , username , password )
104104
105- registry , cfg , err := DockerImageAuth (context . Background (), exampleAuth + "/my/image:latest" )
105+ registry , cfg , err := DockerImageAuth (t . Context (), exampleAuth + "/my/image:latest" )
106106 require .NoError (t , err )
107107 require .Equal (t , exampleAuth , registry )
108108 require .Equal (t , username , cfg .Username )
@@ -115,7 +115,7 @@ func TestDockerImageAuth(t *testing.T) {
115115 imagePath := "/my/image:latest"
116116 base64 := setAuthConfig (t , exampleAuth , "gopher" , "secret" )
117117
118- registry , cfg , err := DockerImageAuth (context . Background (), imageReg + imagePath )
118+ registry , cfg , err := DockerImageAuth (t . Context (), imageReg + imagePath )
119119 require .NoError (t , err )
120120 require .Equal (t , imageReg , registry )
121121 require .Equal (t , "gopher" , cfg .Username )
@@ -130,7 +130,7 @@ func TestDockerImageAuth(t *testing.T) {
130130
131131 setAuthConfig (t , invalidRegistryURL , "gopher" , "secret" )
132132
133- registry , cfg , err := DockerImageAuth (context . Background (), imageReg + imagePath )
133+ registry , cfg , err := DockerImageAuth (t . Context (), imageReg + imagePath )
134134 require .ErrorIs (t , err , dockercfg .ErrCredentialsNotFound )
135135 require .Empty (t , cfg )
136136 require .Equal (t , imageReg , registry )
@@ -150,15 +150,15 @@ func TestDockerImageAuth(t *testing.T) {
150150
151151 setAuthConfig (t , "example-auth.com" , "gopher" , "secret" )
152152
153- registry , cfg , err := DockerImageAuth (context . Background (), imageReg + imagePath )
153+ registry , cfg , err := DockerImageAuth (t . Context (), imageReg + imagePath )
154154 require .ErrorIs (t , err , dockercfg .ErrCredentialsNotFound )
155155 require .Empty (t , cfg )
156156 require .Equal (t , imageReg , registry )
157157 })
158158}
159159
160160func TestBuildContainerFromDockerfile (t * testing.T ) {
161- ctx := context . Background ()
161+ ctx := t . Context ()
162162
163163 redisC , err := Run (ctx , "" ,
164164 WithDockerfile (FromDockerfile {
@@ -175,7 +175,7 @@ func TestBuildContainerFromDockerfile(t *testing.T) {
175175// removeImageFromLocalCache removes the image from the local cache
176176func removeImageFromLocalCache (t * testing.T , img string ) {
177177 t .Helper ()
178- ctx := context . Background ()
178+ ctx := t . Context ()
179179
180180 testcontainersClient , err := NewDockerClientWithOpts (ctx , client .WithVersion (daemonMaxVersion ))
181181 if err != nil {
@@ -198,7 +198,7 @@ func TestBuildContainerFromDockerfileWithDockerAuthConfig(t *testing.T) {
198198 // using the same credentials as in the Docker Registry
199199 setAuthConfig (t , registryHost , "testuser" , "testpassword" )
200200
201- ctx := context . Background ()
201+ ctx := t . Context ()
202202
203203 redisC , err := Run (ctx , "" ,
204204 WithDockerfile (FromDockerfile {
@@ -223,7 +223,7 @@ func TestBuildContainerFromDockerfileShouldFailWithWrongDockerAuthConfig(t *test
223223 // using different credentials than in the Docker Registry
224224 setAuthConfig (t , registryHost , "foo" , "bar" )
225225
226- ctx := context . Background ()
226+ ctx := t . Context ()
227227
228228 redisC , err := Run (ctx , "" ,
229229 WithDockerfile (FromDockerfile {
@@ -247,7 +247,7 @@ func TestCreateContainerFromPrivateRegistry(t *testing.T) {
247247 // using the same credentials as in the Docker Registry
248248 setAuthConfig (t , registryHost , "testuser" , "testpassword" )
249249
250- ctx := context . Background ()
250+ ctx := t . Context ()
251251
252252 redisContainer , err := Run (ctx , registryHost + "/redis:5.0-alpine" , WithAlwaysPull (), WithExposedPorts ("6379/tcp" ), WithWaitStrategy (wait .ForLog ("Ready to accept connections" )))
253253 CleanupContainer (t , redisContainer )
@@ -256,7 +256,7 @@ func TestCreateContainerFromPrivateRegistry(t *testing.T) {
256256
257257func prepareLocalRegistryWithAuth (t * testing.T ) string {
258258 t .Helper ()
259- ctx := context . Background ()
259+ ctx := t . Context ()
260260 wd , err := os .Getwd ()
261261 require .NoError (t , err )
262262 // copyDirectoryToContainer {
0 commit comments