github.com/pachyderm/pachyderm@v1.13.4/src/server/pkg/deploy/assets/assets_test.go (about)

     1  package assets
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/pachyderm/pachyderm/src/client/pkg/require"
     8  )
     9  
    10  func TestAddRegistry_NoSlash(t *testing.T) {
    11  	imageName := "busybox"
    12  	img := AddRegistry("", imageName)
    13  	require.Equal(t, imageName, img)
    14  }
    15  
    16  func TestAddRegistry_OneSlash(t *testing.T) {
    17  	imageName := "library/busybox"
    18  	img := AddRegistry("", imageName)
    19  	require.Equal(t, imageName, img)
    20  }
    21  
    22  func TestAddRegistry_WithRegistry(t *testing.T) {
    23  	imageName := "library/busybox"
    24  	registry := "example.com"
    25  	expected := fmt.Sprintf("%s/%s", registry, imageName)
    26  	img := AddRegistry(registry, imageName)
    27  	require.Equal(t, expected, img)
    28  }
    29  
    30  func TestAddRegistry_SwitchRegistry(t *testing.T) {
    31  	imageTag := "library/busybox"
    32  	originalRegistry := "example.org"
    33  	imageName := fmt.Sprintf("%s/%s", originalRegistry, imageTag)
    34  	registry := "example.com"
    35  	expected := fmt.Sprintf("%s/%s", registry, imageTag)
    36  	img := AddRegistry(registry, imageName)
    37  	require.Equal(t, expected, img)
    38  }