You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
409 B
21 lines
409 B
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func TestInitShortener(t *testing.T) {
|
|
close, err := initShortener()
|
|
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")
|
|
}
|
|
close()
|
|
}
|
|
|