TestMain runs before all tests to build the envbuilder image.
(m *testing.M)
| 2600 | |
| 2601 | // TestMain runs before all tests to build the envbuilder image. |
| 2602 | func TestMain(m *testing.M) { |
| 2603 | checkTestRegistry() |
| 2604 | cleanOldEnvbuilders() |
| 2605 | ctx := context.Background() |
| 2606 | // Run the build script to create the envbuilder image. |
| 2607 | cmd := exec.CommandContext(ctx, "../scripts/build.sh") |
| 2608 | rdr, wtr := io.Pipe() |
| 2609 | defer rdr.Close() |
| 2610 | defer wtr.Close() |
| 2611 | cmd.Stdout = wtr |
| 2612 | cmd.Stderr = wtr |
| 2613 | go func() { |
| 2614 | scanner := bufio.NewScanner(rdr) |
| 2615 | for scanner.Scan() { |
| 2616 | fmt.Println(scanner.Text()) |
| 2617 | } |
| 2618 | }() |
| 2619 | err := cmd.Run() |
| 2620 | if err != nil { |
| 2621 | panic(err) |
| 2622 | } |
| 2623 | |
| 2624 | m.Run() |
| 2625 | } |
| 2626 | |
| 2627 | func checkTestRegistry() { |
| 2628 | resp, err := http.Get("http://localhost:5000/v2/_catalog") |
nothing calls this directly
no test coverage detected