Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve golden file error messages #207

Merged
merged 9 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/microsoftgraph/msgraph-sdk-go v1.48.0
github.com/microsoftgraph/msgraph-sdk-go-core v1.2.1
github.com/otiai10/copy v1.14.0
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -48,7 +49,6 @@ require (
github.com/microsoft/kiota-serialization-text-go v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
Expand Down
16 changes: 6 additions & 10 deletions internal/broker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ func TestGetAuthenticationModes(t *testing.T) {
}
require.NoError(t, err, "GetAuthenticationModes should not have returned an error")

want := testutils.LoadWithUpdateFromGoldenYAML(t, got)
require.Equal(t, want, got, "GetAuthenticationModes should have returned the expected value")
testutils.CheckOrUpdateGoldenYAML(t, got)
})
}
}
Expand Down Expand Up @@ -375,8 +374,7 @@ func TestSelectAuthenticationMode(t *testing.T) {
}
require.NoError(t, err, "SelectAuthenticationMode should not have returned an error")

want := testutils.LoadWithUpdateFromGoldenYAML(t, got)
require.Equal(t, want, got, "SelectAuthenticationMode should have returned the expected layout")
testutils.CheckOrUpdateGoldenYAML(t, got)
})
}
}
Expand Down Expand Up @@ -668,7 +666,7 @@ func TestIsAuthenticated(t *testing.T) {
}
}

testutils.CompareTreesWithFiltering(t, outDir, testutils.GoldenPath(t), testutils.UpdateEnabled())
testutils.CheckOrUpdateGoldenFileTree(t, outDir, testutils.GoldenPath(t))
})
}
}
Expand Down Expand Up @@ -794,7 +792,7 @@ func TestConcurrentIsAuthenticated(t *testing.T) {
t.Logf("Failed to rename issuer data directory: %v", err)
}
}
testutils.CompareTreesWithFiltering(t, outDir, testutils.GoldenPath(t), testutils.UpdateEnabled())
testutils.CheckOrUpdateGoldenFileTree(t, outDir, testutils.GoldenPath(t))
})
}
}
Expand Down Expand Up @@ -871,8 +869,7 @@ func TestFetchUserInfo(t *testing.T) {
}
require.NoError(t, err, "FetchUserInfo should not have returned an error")

want := testutils.LoadWithUpdateFromGoldenYAML(t, got)
require.Equal(t, want, got, "FetchUserInfo should have returned the expected value")
testutils.CheckOrUpdateGoldenYAML(t, got)
})
}
}
Expand Down Expand Up @@ -976,8 +973,7 @@ func TestUserPreCheck(t *testing.T) {
}
require.NoError(t, err, "UserPreCheck should not have returned an error")

want := testutils.LoadWithUpdateFromGolden(t, got)
require.Equal(t, want, got, "UserPreCheck should have returned the expected value")
testutils.CheckOrUpdateGolden(t, got)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/broker/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestParseConfig(t *testing.T) {
err = os.WriteFile(filepath.Join(outDir, "config.txt"), []byte(strings.Join(fields, "\n")), 0600)
require.NoError(t, err)

testutils.CompareTreesWithFiltering(t, outDir, testutils.GoldenPath(t), testutils.UpdateEnabled())
testutils.CheckOrUpdateGoldenFileTree(t, outDir, testutils.GoldenPath(t))
})
}
}
Loading
Loading