summaryrefslogtreecommitdiff
path: root/hack/podman-registry-go/registry_test.go
blob: 4e4bf5fe21199fb4afc5d10c914c1021b1c785a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package registry

import (
	"testing"

	"github.com/hashicorp/go-multierror"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestStartAndStopMultipleRegistries(t *testing.T) {
	binary = "../podman-registry"

	registries := []*Registry{}

	// Start registries.
	var errors *multierror.Error
	for i := 0; i < 3; i++ {
		reg, err := Start()
		if err != nil {
			errors = multierror.Append(errors, err)
			continue
		}
		assert.True(t, len(reg.Image) > 0)
		assert.True(t, len(reg.User) > 0)
		assert.True(t, len(reg.Password) > 0)
		assert.True(t, len(reg.Port) > 0)
		registries = append(registries, reg)
	}

	// Stop registries.
	for _, reg := range registries {
		// Make sure we can stop it properly.
		errors = multierror.Append(errors, reg.Stop())
		// Stopping an already stopped registry is fine as well.
		errors = multierror.Append(errors, reg.Stop())
	}

	require.NoError(t, errors.ErrorOrNil())
}