github.com/containers/podman/v5@v5.1.0-rc1/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  	registryOptions := &Options{
    17  		PodmanPath: "../../bin/podman",
    18  	}
    19  
    20  	// Start registries.
    21  	var errors *multierror.Error
    22  	for i := 0; i < 3; i++ {
    23  		reg, err := StartWithOptions(registryOptions)
    24  		if err != nil {
    25  			errors = multierror.Append(errors, err)
    26  			continue
    27  		}
    28  		assert.True(t, len(reg.Image) > 0)
    29  		assert.True(t, len(reg.User) > 0)
    30  		assert.True(t, len(reg.Password) > 0)
    31  		assert.True(t, len(reg.Port) > 0)
    32  		registries = append(registries, reg)
    33  	}
    34  
    35  	// Stop registries.
    36  	for _, reg := range registries {
    37  		// Make sure we can stop it properly.
    38  		errors = multierror.Append(errors, reg.Stop())
    39  		// Stopping an already stopped registry is fine as well.
    40  		errors = multierror.Append(errors, reg.Stop())
    41  	}
    42  
    43  	require.NoError(t, errors.ErrorOrNil())
    44  }