40 lines
821 B
Go
40 lines
821 B
Go
package docker
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/containerd/containerd/reference"
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
|
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
|
)
|
|
|
|
func TestRepositoryScope(t *testing.T) {
|
|
testCases := []struct {
|
|
refspec reference.Spec
|
|
push bool
|
|
expected string
|
|
}{
|
|
{
|
|
refspec: reference.Spec{
|
|
Locator: "host/foo/bar",
|
|
Object: "ignored",
|
|
},
|
|
push: false,
|
|
expected: "repository:foo/bar:pull",
|
|
},
|
|
{
|
|
refspec: reference.Spec{
|
|
Locator: "host:4242/foo/bar",
|
|
Object: "ignored",
|
|
},
|
|
push: true,
|
|
expected: "repository:foo/bar:pull,push",
|
|
},
|
|
}
|
|
for _, x := range testCases {
|
|
actual, err := repositoryScope(x.refspec, x.push)
|
|
assert.Check(t, is.NilError(err))
|
|
assert.Check(t, is.Equal(x.expected, actual))
|
|
}
|
|
}
|