@@ -32,7 +32,7 @@ func ExampleHTTPStrategy() {
32
32
WaitingFor : wait .ForHTTP ("/" ).WithStartupTimeout (10 * time .Second ),
33
33
}
34
34
35
- gogs , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
35
+ c , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
36
36
ContainerRequest : req ,
37
37
Started : true ,
38
38
})
@@ -42,12 +42,12 @@ func ExampleHTTPStrategy() {
42
42
// }
43
43
44
44
defer func () {
45
- if err := gogs .Terminate (ctx ); err != nil {
45
+ if err := c .Terminate (ctx ); err != nil {
46
46
log .Fatalf ("failed to terminate container: %s" , err )
47
47
}
48
48
}()
49
49
50
- state , err := gogs .State (ctx )
50
+ state , err := c .State (ctx )
51
51
if err != nil {
52
52
panic (err )
53
53
}
@@ -67,7 +67,7 @@ func ExampleHTTPStrategy_WithPort() {
67
67
WaitingFor : wait .ForHTTP ("/" ).WithPort ("80/tcp" ),
68
68
}
69
69
70
- gogs , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
70
+ c , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
71
71
ContainerRequest : req ,
72
72
Started : true ,
73
73
})
@@ -77,12 +77,45 @@ func ExampleHTTPStrategy_WithPort() {
77
77
// }
78
78
79
79
defer func () {
80
- if err := gogs .Terminate (ctx ); err != nil {
80
+ if err := c .Terminate (ctx ); err != nil {
81
81
log .Fatalf ("failed to terminate container: %s" , err )
82
82
}
83
83
}()
84
84
85
- state , err := gogs .State (ctx )
85
+ state , err := c .State (ctx )
86
+ if err != nil {
87
+ panic (err )
88
+ }
89
+
90
+ fmt .Println (state .Running )
91
+
92
+ // Output:
93
+ // true
94
+ }
95
+
96
+ func ExampleHTTPStrategy_WithForcedIPv4LocalHost () {
97
+ ctx := context .Background ()
98
+ req := testcontainers.ContainerRequest {
99
+ Image : "nginx:latest" ,
100
+ ExposedPorts : []string {"8080/tcp" , "80/tcp" },
101
+ WaitingFor : wait .ForHTTP ("/" ).WithForcedIPv4LocalHost (),
102
+ }
103
+
104
+ c , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
105
+ ContainerRequest : req ,
106
+ Started : true ,
107
+ })
108
+ if err != nil {
109
+ panic (err )
110
+ }
111
+
112
+ defer func () {
113
+ if err := c .Terminate (ctx ); err != nil {
114
+ log .Fatalf ("failed to terminate container: %s" , err )
115
+ }
116
+ }()
117
+
118
+ state , err := c .State (ctx )
86
119
if err != nil {
87
120
panic (err )
88
121
}
0 commit comments