mirror of https://github.com/kubernetes/kops.git
Move abs resolution a bit earlier to make it clear where we are looking for golden output
This commit is contained in:
parent
bac4afa3e5
commit
5e7ec64347
|
@ -33,6 +33,13 @@ import (
|
||||||
func AssertMatchesFile(t *testing.T, actual string, p string) {
|
func AssertMatchesFile(t *testing.T, actual string, p string) {
|
||||||
actual = strings.TrimSpace(actual)
|
actual = strings.TrimSpace(actual)
|
||||||
|
|
||||||
|
abs, err := filepath.Abs(p)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unable to get absolute path for %q: %v", p, err)
|
||||||
|
} else {
|
||||||
|
p = abs
|
||||||
|
}
|
||||||
|
|
||||||
expectedBytes, err := ioutil.ReadFile(p)
|
expectedBytes, err := ioutil.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) || os.Getenv("HACK_UPDATE_EXPECTED_IN_PLACE") == "" {
|
if !os.IsNotExist(err) || os.Getenv("HACK_UPDATE_EXPECTED_IN_PLACE") == "" {
|
||||||
|
@ -69,13 +76,6 @@ func AssertMatchesFile(t *testing.T, actual string, p string) {
|
||||||
diffString := diff.FormatDiff(expected, actual)
|
diffString := diff.FormatDiff(expected, actual)
|
||||||
t.Logf("diff:\n%s\n", diffString)
|
t.Logf("diff:\n%s\n", diffString)
|
||||||
|
|
||||||
abs, err := filepath.Abs(p)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unable to get absolute path for %q: %v", p, err)
|
|
||||||
} else {
|
|
||||||
p = abs
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("to update golden output automatically, run hack/update-expected.sh")
|
t.Logf("to update golden output automatically, run hack/update-expected.sh")
|
||||||
|
|
||||||
t.Errorf("output did not match expected for %q", p)
|
t.Errorf("output did not match expected for %q", p)
|
||||||
|
|
Loading…
Reference in New Issue