Skip to content

Commit

Permalink
Add a one-second delay before the mock HTTP server starts in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amerkurev committed Oct 31, 2023
1 parent 6b3603f commit 917cc2e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/bindmount/size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Test_Run(t *testing.T) {
addr := fmt.Sprintf("127.0.0.1:%d", port)
mock := docker.NewMockServer(addr, version, logFile, mountDir)
mock.Start(t)
time.Sleep(10 * time.Millisecond)
time.Sleep(time.Second)

ctx, cancel := context.WithCancel(context.Background())
d, err := docker.NewClient(ctx, "http://"+addr, "", version, false)
Expand Down Expand Up @@ -82,7 +82,7 @@ func Test_Run_NoSuchFileOrDir(t *testing.T) {
version := "v1.22"
mock := docker.NewMockServer(addr, version, "incorrect-path", "incorrect-path")
mock.Start(t)
time.Sleep(10 * time.Millisecond)
time.Sleep(time.Second)

ctx, cancel := context.WithCancel(context.Background())
d, err := docker.NewClient(ctx, "http://"+addr, "", version, false)
Expand All @@ -106,7 +106,7 @@ func Test_Run_Failed(t *testing.T) {
addr := fmt.Sprintf("127.0.0.1:%d", port)
mock := docker.NewMockServer(addr, "", "", "")
mock.Start(t)
time.Sleep(10 * time.Millisecond)
time.Sleep(time.Second)

ctx, cancel := context.WithCancel(context.Background())
d, err := docker.NewClient(ctx, "http://"+addr, "", "", false)
Expand Down
2 changes: 1 addition & 1 deletion app/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func Test_Client(t *testing.T) {
version := "v1.22"
mock := NewMockServer(addr, version, "", "")
mock.Start(t)
time.Sleep(time.Second)

time.Sleep(10 * time.Millisecond)
ctx := context.Background()

// bad host
Expand Down
4 changes: 4 additions & 0 deletions app/http/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func Test_Handler(t *testing.T) {
version := "v1.22"
mock := docker.NewMockServer(dockerMockAddr, version, logFile, mountDir)
mock.Start(t)
time.Sleep(time.Second)

d, err := docker.NewClient(ctx, "http://"+dockerMockAddr, "", version, false)
require.NoError(t, err)

Expand Down Expand Up @@ -131,6 +133,8 @@ func Test_FailedToGetLogFile(t *testing.T) {
version := "v1.22"
mock := docker.NewMockServer(dockerMockAddr, version, "incorrect-path", "incorrect-path")
mock.Start(t)
time.Sleep(time.Second)

d, err := docker.NewClient(ctx, "http://"+dockerMockAddr, "", version, false)
require.NoError(t, err)

Expand Down
4 changes: 4 additions & 0 deletions app/http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func Test_Server_Run(t *testing.T) {
version := "v1.22"
mock := docker.NewMockServer(dockerMockAddr, version, logFile, mountDir)
mock.Start(t)
time.Sleep(time.Second)

d, err := docker.NewClient(ctx, "http://"+dockerMockAddr, "", version, false)
require.NoError(t, err)

Expand Down Expand Up @@ -152,6 +154,8 @@ func Test_Server_RunFailed(t *testing.T) {
version := "v1.22"
mock := docker.NewMockServer(dockerMockAddr, version, "", "")
mock.Start(t)
time.Sleep(time.Second)

d, err := docker.NewClient(ctx, "http://"+addr, "", version, false)
require.NoError(t, err)

Expand Down

0 comments on commit 917cc2e

Please sign in to comment.