Skip to content

Commit

Permalink
Add missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
banjoh committed Sep 22, 2023
1 parent 2c9bcda commit bfc6e4f
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions pkg/oci/pull_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package oci

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_parseURI(t *testing.T) {
tests := []struct {
name string
uri string
imageName string
wantUri string
wantErr bool
}{
{
name: "happy path",
uri: "oci://registry.replicated.com/app-slug/unstable",
imageName: "replicated-preflight",
wantUri: "registry.replicated.com/app-slug/unstable/replicated-preflight:latest",
},
{
name: "no path in uri",
uri: "oci://registry.replicated.com",
imageName: "replicated-preflight",
wantUri: "registry.replicated.com/replicated-preflight:latest",
},
{
name: "hostname with port",
uri: "oci://localhost:5000/some/path",
imageName: "replicated-preflight",
wantUri: "localhost:5000/some/path/replicated-preflight:latest",
},
{
name: "uri with tags",
uri: "oci://localhost:5000/some/path:tag",
imageName: "replicated-preflight",
wantUri: "localhost:5000/some/path/replicated-preflight:tag",
},
{
name: "empty uri",
wantErr: true,
},
{
name: "invalid uri",
uri: "registry.replicated.com/app-slug/unstable",
imageName: "replicated-preflight",
wantErr: true,
},
{
name: "invalid uri",
uri: "https://registry.replicated.com/app-slug/unstable",
imageName: "replicated-preflight",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := parseURI(tt.uri, tt.imageName)
require.Equalf(t, tt.wantErr, err != nil, "parseURI() error = %v, wantErr %v", err, tt.wantErr)
assert.Equalf(t, tt.wantUri, got, "parseURI() = %v, want %v", got, tt.wantUri)
})
}
}

0 comments on commit bfc6e4f

Please sign in to comment.