github.com/vcilabs/webrpc@v0.5.2-0.20201116131534-162e27b1b33b/_examples/golang-imports/api_test.go (about) 1 package main 2 3 import ( 4 "context" 5 "net/http" 6 "testing" 7 "time" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 var ( 13 client ExampleAPI 14 ) 15 16 // func TestMain() 17 18 func init() { 19 go func() { 20 startServer() 21 }() 22 23 client = NewExampleAPIClient("http://0.0.0.0:4242", &http.Client{ 24 Timeout: time.Duration(2 * time.Second), 25 }) 26 time.Sleep(time.Millisecond * 500) 27 28 } 29 30 func TestPing(t *testing.T) { 31 err := client.Ping(context.Background()) 32 assert.NoError(t, err) 33 } 34 35 func TestStatus(t *testing.T) { 36 resp, err := client.Status(context.Background()) 37 assert.Equal(t, true, resp) 38 assert.NoError(t, err) 39 }