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

Loading…
Cancel
Save