fix ServiceCmd/Format test

pull/15961/head
Steven Powell 2023-03-03 10:01:30 -08:00
parent 3dd2006de7
commit ed78682de9
1 changed files with 4 additions and 9 deletions

View File

@ -25,6 +25,7 @@ import (
"encoding/json"
"fmt"
"io"
"net"
"net/http"
"net/url"
"os"
@ -1539,16 +1540,10 @@ func validateServiceCmdFormat(ctx context.Context, t *testing.T, profile string)
t.Errorf("failed to get service url with custom format. args %q: %v", rr.Command(), err)
}
endpoint := strings.TrimSpace(rr.Stdout.String())
t.Logf("found endpoint for hello-node: %s", endpoint)
stringIP := strings.TrimSpace(rr.Stdout.String())
u, err := url.Parse(endpoint)
if err != nil {
t.Fatalf("failed to parse %q: %v", endpoint, err)
}
if strings.TrimSpace(rr.Stdout.String()) != u.Hostname() {
t.Errorf("expected 'service --format={{.IP}}' output to be -%q- but got *%q* . args %q.", u.Hostname(), rr.Stdout.String(), rr.Command())
if ip := net.ParseIP(stringIP); ip == nil {
t.Fatalf("%q is not a valid IP", stringIP)
}
})
}