assertVersionFile checks that goa.json was emitted with the correct version and returns the remaining outputs (excluding goa.json) for further assertions.
(t *testing.T, dir string, outputs []string)
| 292 | // assertVersionFile checks that goa.json was emitted with the correct version |
| 293 | // and returns the remaining outputs (excluding goa.json) for further assertions. |
| 294 | func assertVersionFile(t *testing.T, dir string, outputs []string) []string { |
| 295 | t.Helper() |
| 296 | |
| 297 | versionPath := filepath.Join(codegen.Gendir, "goa.json") |
| 298 | |
| 299 | // Read and validate goa.json content. |
| 300 | bs, err := os.ReadFile(filepath.Join(dir, versionPath)) |
| 301 | if err != nil { |
| 302 | t.Fatalf("failed reading goa.json: %v", err) |
| 303 | } |
| 304 | var data map[string]string |
| 305 | if err := json.Unmarshal(bs, &data); err != nil { |
| 306 | t.Fatalf("goa.json is not valid JSON: %v", err) |
| 307 | } |
| 308 | if v := data["goa_version"]; v != goa.Version() { |
| 309 | t.Fatalf("goa.json version = %q, want %q", v, goa.Version()) |
| 310 | } |
| 311 | |
| 312 | // Filter goa.json out of outputs. |
| 313 | var rest []string |
| 314 | for _, o := range outputs { |
| 315 | if filepath.Base(o) != "goa.json" { |
| 316 | rest = append(rest, o) |
| 317 | } |
| 318 | } |
| 319 | return rest |
| 320 | } |
no outgoing calls
no test coverage detected