Skip to content

Commit

Permalink
try to ensure server is running for certs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed Jan 4, 2024
1 parent 035282a commit 41984c3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/pkg/api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,18 @@ func Test_server_ClientCert(t *testing.T) {
},
}

started := make(chan struct{}, 1)
var wg sync.WaitGroup
wg.Add(1)
go func() {
started <- struct{}{}
if err := srv.Run(ctx); err != nil {
errCh <- err
}
wg.Done()
}()

<-started
rCtx, rCancel := context.WithTimeout(ctx, time.Second)
defer rCancel()
req, err := http.NewRequestWithContext(rCtx, "GET", "https://"+addr+"/api/status", nil)
Expand Down Expand Up @@ -198,15 +201,18 @@ func Test_server_ClientCert(t *testing.T) {
},
}

started := make(chan struct{}, 1)
var wg sync.WaitGroup
wg.Add(1)
go func() {
started <- struct{}{}
if err := srv.Run(ctx); err != nil {
errCh <- err
}
wg.Done()
}()

<-started
rCtx, rCancel := context.WithTimeout(ctx, time.Second)
defer rCancel()
req, err := http.NewRequestWithContext(rCtx, "GET", "https://"+addr+"/api/status", nil)
Expand Down Expand Up @@ -256,15 +262,18 @@ func Test_server_ClientCert(t *testing.T) {
},
}

started := make(chan struct{}, 1)
var wg sync.WaitGroup
wg.Add(1)
go func() {
started <- struct{}{}
if err := srv.Run(ctx); err != nil {
errCh <- err
}
wg.Done()
}()

<-started
rCtx, rCancel := context.WithTimeout(ctx, time.Second)
defer rCancel()
req, err := http.NewRequestWithContext(rCtx, "GET", "https://"+addr+"/api/status", nil)
Expand Down

0 comments on commit 41984c3

Please sign in to comment.