github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/hack/podman-registry-go/registry_test.go (about) 1 package registry 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/go-multierror" 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestStartAndStopMultipleRegistries(t *testing.T) { 12 binary = "../podman-registry" 13 14 registries := []*Registry{} 15 16 // Start registries. 17 var errors *multierror.Error 18 for i := 0; i < 3; i++ { 19 reg, err := Start() 20 if err != nil { 21 errors = multierror.Append(errors, err) 22 continue 23 } 24 assert.True(t, len(reg.Image) > 0) 25 assert.True(t, len(reg.User) > 0) 26 assert.True(t, len(reg.Password) > 0) 27 assert.True(t, len(reg.Port) > 0) 28 registries = append(registries, reg) 29 } 30 31 // Stop registries. 32 for _, reg := range registries { 33 // Make sure we can stop it properly. 34 errors = multierror.Append(errors, reg.Stop()) 35 // Stopping an already stopped registry is fine as well. 36 errors = multierror.Append(errors, reg.Stop()) 37 } 38 39 require.NoError(t, errors.ErrorOrNil()) 40 }