package main import ( "net" "net/http" "reflect" "testing" "time" "gitlab.com/khanzf/fedilogue/shared" ) func TestBuildClient(t *testing.T) { tr := &http.Transport{ MaxIdleConns: 2, IdleConnTimeout: 3600 * time.Second, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, } want := http.Client{Transport: tr} have := BuildClient("testdomain.com") if reflect.DeepEqual(want, have) { t.Fatalf("TestBuildClient client different from expected.") } } func TestBuildClientProxy(t *testing.T) { // Currently not implemented } func TestGetRunnerNonExist(t *testing.T) { // Currently not implemented } func TestGetRunnerExists(t *testing.T) { defer func() { runninginstances = map[string]shared.RunningInstance{} }() want_o := shared.RunningInstance{} want_o.Client = BuildClient("some-non-existent-domain.tld") want_o.Status = shared.KEEPALIVE want_o.Recentactivities = shared.NewUniqueFifo(10) want_o.Recentactors = shared.NewUniqueFifo(10) runninginstances["some-non-existent-domain.tld"] = want_o want_exists := true _, have_exists := GetRunner("some-non-existent-domain.tld") if have_exists != want_exists { t.Fatalf("TestGetRunnerBlank expected %v, got %v", want_exists, have_exists) } // if reflect.DeepEqual(want_o, have_o) { // t.Fatalf("TestGetRunnerExists failed, should have the same value") // } }