@@ -96,20 +96,18 @@ func TestRunContainer_authenticated(t *testing.T) {
9696 t .Run ("build images with wrong credentials fails" , func (tt * testing.T ) {
9797 setAuthConfig (tt , registryHost , "foo" , "bar" )
9898
99- redisC , err := testcontainers .GenericContainer (context .Background (), testcontainers.GenericContainerRequest {
100- ContainerRequest : testcontainers.ContainerRequest {
101- FromDockerfile : testcontainers.FromDockerfile {
102- Context : filepath .Join ("testdata" , "redis" ),
103- BuildArgs : map [string ]* string {
104- "REGISTRY_HOST" : & registryHost ,
105- },
99+ redisC , err := testcontainers .Run (
100+ context .Background (), "" ,
101+ testcontainers .WithDockerfile (testcontainers.FromDockerfile {
102+ Context : filepath .Join ("testdata" , "redis" ),
103+ BuildArgs : map [string ]* string {
104+ "REGISTRY_HOST" : & registryHost ,
106105 },
107- AlwaysPullImage : true , // make sure the authentication takes place
108- ExposedPorts : []string {"6379/tcp" },
109- WaitingFor : wait .ForLog ("Ready to accept connections" ),
110- },
111- Started : true ,
112- })
106+ }),
107+ testcontainers .WithAlwaysPull (), // make sure the authentication takes place
108+ testcontainers .WithExposedPorts ("6379/tcp" ),
109+ testcontainers .WithWaitStrategy (wait .ForLog ("Ready to accept connections" )),
110+ )
113111 testcontainers .CleanupContainer (tt , redisC )
114112 require .Error (tt , err )
115113 require .Contains (tt , err .Error (), "unauthorized: authentication required" )
@@ -123,20 +121,18 @@ func TestRunContainer_authenticated(t *testing.T) {
123121 // The container should start because the authentication
124122 // is correct.
125123
126- redisC , err := testcontainers .GenericContainer (context .Background (), testcontainers.GenericContainerRequest {
127- ContainerRequest : testcontainers.ContainerRequest {
128- FromDockerfile : testcontainers.FromDockerfile {
129- Context : filepath .Join ("testdata" , "redis" ),
130- BuildArgs : map [string ]* string {
131- "REGISTRY_HOST" : & registryHost ,
132- },
124+ redisC , err := testcontainers .Run (
125+ context .Background (), "" ,
126+ testcontainers .WithDockerfile (testcontainers.FromDockerfile {
127+ Context : filepath .Join ("testdata" , "redis" ),
128+ BuildArgs : map [string ]* string {
129+ "REGISTRY_HOST" : & registryHost ,
133130 },
134- AlwaysPullImage : true , // make sure the authentication takes place
135- ExposedPorts : []string {"6379/tcp" },
136- WaitingFor : wait .ForLog ("Ready to accept connections" ),
137- },
138- Started : true ,
139- })
131+ }),
132+ testcontainers .WithAlwaysPull (), // make sure the authentication takes place
133+ testcontainers .WithExposedPorts ("6379/tcp" ),
134+ testcontainers .WithWaitStrategy (wait .ForLog ("Ready to accept connections" )),
135+ )
140136 testcontainers .CleanupContainer (tt , redisC )
141137 require .NoError (tt , err )
142138
@@ -256,20 +252,17 @@ func TestRunContainer_wrongData(t *testing.T) {
256252 // The container won't be able to start because the data
257253 // directory is wrong.
258254
259- redisC , err := testcontainers .GenericContainer (context .Background (), testcontainers.GenericContainerRequest {
260- ContainerRequest : testcontainers.ContainerRequest {
261- FromDockerfile : testcontainers.FromDockerfile {
262- Context : filepath .Join ("testdata" , "redis" ),
263- BuildArgs : map [string ]* string {
264- "REGISTRY_HOST" : & registryHost ,
265- },
255+ redisC , err := testcontainers .Run (context .Background (), "" ,
256+ testcontainers .WithDockerfile (testcontainers.FromDockerfile {
257+ Context : filepath .Join ("testdata" , "redis" ),
258+ BuildArgs : map [string ]* string {
259+ "REGISTRY_HOST" : & registryHost ,
266260 },
267- AlwaysPullImage : true , // make sure the authentication takes place
268- ExposedPorts : []string {"6379/tcp" },
269- WaitingFor : wait .ForLog ("Ready to accept connections" ),
270- },
271- Started : true ,
272- })
261+ }),
262+ testcontainers .WithAlwaysPull (), // make sure the authentication takes place
263+ testcontainers .WithExposedPorts ("6379/tcp" ),
264+ testcontainers .WithWaitStrategy (wait .ForLog ("Ready to accept connections" )),
265+ )
273266 testcontainers .CleanupContainer (t , redisC )
274267 require .ErrorContains (t , err , "manifest unknown" )
275268}
0 commit comments