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" "encoding/json"
"fmt" "fmt"
"io" "io"
"net"
"net/http" "net/http"
"net/url" "net/url"
"os" "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) t.Errorf("failed to get service url with custom format. args %q: %v", rr.Command(), err)
} }
endpoint := strings.TrimSpace(rr.Stdout.String()) stringIP := strings.TrimSpace(rr.Stdout.String())
t.Logf("found endpoint for hello-node: %s", endpoint)
u, err := url.Parse(endpoint) if ip := net.ParseIP(stringIP); ip == nil {
if err != nil { t.Fatalf("%q is not a valid IP", stringIP)
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())
} }
}) })
} }