Skip to content

Commit f2bd998

Browse files
committed
♻️ Handle turned down services when waiting
1 parent 1440e56 commit f2bd998

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

localstack_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func TestLocalStackWithIndividualServicesOnContext(t *testing.T) {
252252
dialer := &net.Dialer{Timeout: time.Second}
253253
for service := range localstack.AvailableServices {
254254
t.Run(service.Name, func(t *testing.T) {
255-
ctx, cancel := context.WithCancel(context.Background())
255+
ctx, cancel := context.WithCancel(t.Context())
256256
l, err := localstack.NewInstance()
257257
require.NoError(t, err)
258258
require.NoError(t, l.StartWithContext(ctx, service))
@@ -267,7 +267,11 @@ func TestLocalStackWithIndividualServicesOnContext(t *testing.T) {
267267

268268
// wait until service was shutdown
269269
require.Eventually(t, func() bool {
270-
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, l.EndpointV2(service), nil)
270+
address := l.EndpointV2(service)
271+
if address == "" {
272+
return true
273+
}
274+
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, address, nil)
271275
res, err := cl.Do(req)
272276
defer func() {
273277
if res == nil || res.Body == nil {
@@ -300,7 +304,11 @@ func TestLocalStackWithIndividualServices(t *testing.T) {
300304

301305
// wait until service was shutdown
302306
require.Eventually(t, func() bool {
303-
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, l.EndpointV2(service), nil)
307+
address := l.EndpointV2(service)
308+
if address == "" {
309+
return true
310+
}
311+
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, address, nil)
304312
res, err := cl.Do(req)
305313
defer func() {
306314
if res == nil || res.Body == nil {

0 commit comments

Comments
 (0)