Skip to content

Commit 4c3a77d

Browse files
authored
chore(tests): add makefile target to update JSON snapshots (containers#515)
Signed-off-by: Marc Nuri <[email protected]>
1 parent 6491561 commit 4c3a77d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ build-all-platforms: clean tidy format lint ## Build the project for all platfor
5858
test: ## Run the tests
5959
go test -count=1 -v ./...
6060

61+
.PHONY: test-update-snapshots
62+
test-update-snapshots: ## Update test snapshots for toolset tests
63+
UPDATE_TOOLSETS_JSON=1 go test -count=1 -v ./pkg/mcp
64+
6165
.PHONY: format
6266
format: ## Format the code
6367
go fmt ./...

pkg/mcp/toolsets_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ func (s *ToolsetsSuite) InitMcpClient() {
203203
s.McpClient = test.NewMcpClient(s.T(), s.mcpServer.ServeHTTP())
204204
}
205205

206+
// assertJsonSnapshot compares actual data against a JSON snapshot file.
207+
// When the snapshot doesn't match, the test fails with instructions on how to update it.
208+
// Set UPDATE_TOOLSETS_JSON=1 environment variable to regenerate snapshot files.
209+
// Example: UPDATE_TOOLSETS_JSON=1 go test ./pkg/mcp -v
206210
func (s *ToolsetsSuite) assertJsonSnapshot(snapshotFile string, actual any) {
207211
_, file, _, _ := runtime.Caller(1)
208212
snapshotPath := filepath.Join(filepath.Dir(file), "testdata", snapshotFile)

0 commit comments

Comments
 (0)