fix: print correct listen adress in coder server (#5634)

This commit is contained in:
Colin Adler
2023-01-09 13:59:23 -06:00
committed by GitHub
parent 68324c7263
commit 7bcbf197c1
2 changed files with 82 additions and 2 deletions

View File

@ -674,6 +674,58 @@ func TestServer(t *testing.T) {
}
})
t.Run("CanListenUnspecifiedv4", func(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
root, _ := clitest.New(t,
"server",
"--in-memory",
"--http-address", "0.0.0.0:0",
"--access-url", "http://example.com",
)
pty := ptytest.New(t)
root.SetOutput(pty.Output())
root.SetErr(pty.Output())
errC := make(chan error, 1)
go func() {
errC <- root.ExecuteContext(ctx)
}()
pty.ExpectMatch("Started HTTP listener at http://0.0.0.0:")
cancelFunc()
require.NoError(t, <-errC)
})
t.Run("CanListenUnspecifiedv6", func(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
root, _ := clitest.New(t,
"server",
"--in-memory",
"--http-address", "[::]:0",
"--access-url", "http://example.com",
)
pty := ptytest.New(t)
root.SetOutput(pty.Output())
root.SetErr(pty.Output())
errC := make(chan error, 1)
go func() {
errC <- root.ExecuteContext(ctx)
}()
pty.ExpectMatch("Started HTTP listener at http://[::]:")
cancelFunc()
require.NoError(t, <-errC)
})
t.Run("NoAddress", func(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background())