| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 | package hhaimport (	"context"	"testing"	"time")func TestHttpHighAvailability_ServeHTTP(t *testing.T) {	addr := "http://192.168.0.10:8001"	path := "/alive"	serverList := []string{		"http://192.168.0.10:8001",		"http://192.168.0.10:8002",	}	ha := New(addr, path, serverList)	go func() {		for {			time.Sleep(1 * time.Second)			t.Log(addr, ha.Alive)		}	}()	if err := ha.Start(context.Background()); err != nil {		t.Error(err)	}}func TestHttpHighAvailability_Start(t *testing.T) {	addr := "http://192.168.0.10:8002"	path := "/alive"	serverList := []string{		"http://192.168.0.10:8001",		"http://192.168.0.10:8002",	}	ha := New(addr, path, serverList)	go func() {		for {			time.Sleep(1 * time.Second)			t.Log(addr, ha.Alive)		}	}()	if err := ha.Start(context.Background()); err != nil {		t.Fatal(err)	}}
 |