summaryrefslogtreecommitdiffstats
path: root/commands/server_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-04-12 09:31:53 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-04-12 09:31:53 +0200
commit9c782d5147bfea0dd85cf3374f598f0176f204eb (patch)
treec4c84ca793cfa652eec83b911fb1685700431094 /commands/server_test.go
parent14c35c8a56c4dc9a1ee0053e9ff976be7715ba99 (diff)
downloadhugo-9c782d5147bfea0dd85cf3374f598f0176f204eb.tar.gz
hugo-9c782d5147bfea0dd85cf3374f598f0176f204eb.zip
commands: Fix failing Travis server test
Diffstat (limited to 'commands/server_test.go')
-rw-r--r--commands/server_test.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/commands/server_test.go b/commands/server_test.go
index b17addf6b..648664697 100644
--- a/commands/server_test.go
+++ b/commands/server_test.go
@@ -38,9 +38,9 @@ func TestServer(t *testing.T) {
os.RemoveAll(dir)
}()
- stop, started := make(chan bool), make(chan bool)
+ stop := make(chan bool)
- scmd := newServerCmdSignaled(stop, started)
+ scmd := newServerCmdSignaled(stop)
cmd := scmd.getCommand()
cmd.SetArgs([]string{"-s=" + dir, fmt.Sprintf("-p=%d", port)})
@@ -50,11 +50,10 @@ func TestServer(t *testing.T) {
assert.NoError(err)
}()
- select {
- case <-started:
- case <-time.After(2 * time.Second):
- t.Fatal("server start took too long")
- }
+ // There is no way to know exactly when the server is ready for connections.
+ // We could improve by something like https://golang.org/pkg/net/http/httptest/#Server
+ // But for now, let us sleep and pray!
+ time.Sleep(2 * time.Second)
resp, err := http.Get("http://localhost:1331/")
assert.NoError(err)