websvc: add dns and http apis

This commit is contained in:
Ainar Garipov
2022-08-31 17:53:45 +03:00
parent c098960b39
commit 27bd8bc58b
11 changed files with 547 additions and 42 deletions

View File

@@ -25,7 +25,7 @@ var testStart = time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC)
// instance down.
//
// TODO(a.garipov): Use svc or remove it.
func newTestServer(t testing.TB) (svc *websvc.Service, addr string) {
func newTestServer(t testing.TB) (svc *websvc.Service, addr netip.AddrPort) {
t.Helper()
c := &websvc.Config{
@@ -48,10 +48,11 @@ func newTestServer(t testing.TB) (svc *websvc.Service, addr string) {
require.NoError(t, err)
})
addrs := svc.Addrs()
require.Len(t, addrs, 1)
c = svc.Config()
require.NotNil(t, c)
require.Len(t, c.Addresses, 1)
return svc, addrs[0]
return svc, c.Addresses[0]
}
// httpGet is a helper that performs an HTTP GET request and returns the body of
@@ -83,7 +84,7 @@ func TestService_Start_getHealthCheck(t *testing.T) {
_, addr := newTestServer(t)
u := &url.URL{
Scheme: "http",
Host: addr,
Host: addr.String(),
Path: websvc.PathHealthCheck,
}