Browse Source

Finally fixed CI test

dependabot/npm_and_yarn/web/prismjs-1.21.0
Max Schmitt 8 years ago
parent
commit
96e45c7e33
  1. 9
      main_test.go

9
main_test.go

@ -1,7 +1,7 @@
package main
import (
"net/http"
"net"
"os"
"testing"
"time"
@ -14,9 +14,10 @@ func TestInitShortener(t *testing.T) {
if err != nil {
t.Fatalf("could not init shortener: %v", err)
}
time.Sleep(1) // Give the http server a second to boot up
if err := http.ListenAndServe(viper.GetString("listen_addr"), nil); err == nil {
t.Fatal("port is not in use")
time.Sleep(time.Second) // Give the http server a second to boot up
// We expect there a port is in use error
if _, err := net.Listen("tcp", viper.GetString("listen_addr")); err == nil {
t.Fatalf("port is not in use: %v", err)
}
close()
os.Exit(0)

Loading…
Cancel
Save