Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Fix flaky test on windows
Browse files Browse the repository at this point in the history
Windows github machines are flaky, and running hostname on them
sometimes returns short name, sometimes fqdn. Not sure what is the
cause. Workaround is to ignore results from `hostname' which do not have
`.' in them.
  • Loading branch information
Tomas Volf authored and graywolf-at-work committed Jan 26, 2022
1 parent b9f1f6f commit 7301c3e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions fqdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ func TestFromLookup(t *testing.T) {
for _, tc := range testCases {
fqdn, err := fromLookup(tc.host)
if !errors.Is(err, tc.err) {
t.Fatalf("Unexpected error.\n"+
t.Fatalf("Unexpected error (%q).\n"+
"\tExpected: %T\n"+
"\tActual : %T\n",
tc.err, err)
tc.host, tc.err, err)
}
if fqdn != tc.fqdn {
t.Fatalf("Fqdn does not match.\n"+
t.Fatalf("Fqdn does not match (%q).\n"+
"\tExpected: %q\n"+
"\tActual : %q\n",
tc.fqdn, fqdn)
tc.host, tc.fqdn, fqdn)
}
}
}
Expand Down Expand Up @@ -100,6 +100,14 @@ func TestMatchHostname(t *testing.T) {
outS = strings.ToLower(outS)
fqdn = strings.ToLower(fqdn)

// Windows github machines are flaky, and running hostname on them
// sometimes returns short name, sometimes fqdn. Not sure what is the
// cause. Workaround is to ignore results from the system which do not
// have `.' in them.
if !strings.ContainsRune(outS, '.') {
return
}

if outS != fqdn {
t.Fatalf("Output from hostname does not match.\n"+
"\tUs : %q\n"+
Expand Down

0 comments on commit 7301c3e

Please sign in to comment.