Example: Format-aware comparisons
(t *testing.T)
| 23 | |
| 24 | // Example: Format-aware comparisons |
| 25 | func TestFormatAwareComparisons(t *testing.T) { |
| 26 | // Test Go code - automatically formatted (auto-detected by .go.golden) |
| 27 | goCode := `package main |
| 28 | import "fmt" |
| 29 | func main(){fmt.Println("unformatted")}` |
| 30 | |
| 31 | testutil.AssertGo(t, "testdata/golden/formatted.go.golden", goCode) |
| 32 | |
| 33 | // Test JSON - automatically pretty-printed (auto-detected by .json.golden) |
| 34 | jsonData := []byte(`{"name":"test","value":42,"items":["a","b","c"]}`) |
| 35 | |
| 36 | testutil.AssertJSON(t, "testdata/golden/config.json.golden", jsonData) |
| 37 | } |
| 38 | |
| 39 | // Example: Testing with subtests |
| 40 | func TestWithSubtests(t *testing.T) { |
nothing calls this directly
no test coverage detected