Skip to content

Commit 62879ef

Browse files
johnstcnmafredri
andauthored
integration: check for test registry on start (#189)
Co-authored-by: Mathias Fredriksson <[email protected]>
1 parent b8e2947 commit 62879ef

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

integration/integration_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ COPY %s .`, testImageAlpine, inclFile)
869869

870870
// TestMain runs before all tests to build the envbuilder image.
871871
func TestMain(m *testing.M) {
872+
checkTestRegistry()
872873
cleanOldEnvbuilders()
873874
ctx := context.Background()
874875
// Run the build script to create the envbuilder image.
@@ -919,6 +920,22 @@ func createGitServer(t *testing.T, opts gitServerOptions) *httptest.Server {
919920
return httptest.NewServer(opts.authMW(gittest.NewServer(fs)))
920921
}
921922

923+
func checkTestRegistry() {
924+
resp, err := http.Get("http://localhost:5000/v2/_catalog")
925+
if err != nil {
926+
_, _ = fmt.Printf("Check test registry: %s\n", err.Error())
927+
_, _ = fmt.Printf("Hint: Did you run `make test-registry`?\n")
928+
os.Exit(1)
929+
}
930+
defer resp.Body.Close()
931+
v := make(map[string][]string)
932+
if err := json.NewDecoder(resp.Body).Decode(&v); err != nil {
933+
_, _ = fmt.Printf("Read test registry catalog: %s\n", err.Error())
934+
_, _ = fmt.Printf("Hint: Did you run `make test-registry`?\n")
935+
os.Exit(1)
936+
}
937+
}
938+
922939
// cleanOldEnvbuilders removes any old envbuilder containers.
923940
func cleanOldEnvbuilders() {
924941
ctx := context.Background()

0 commit comments

Comments
 (0)