github.com/jfrog/jfrog-cli-core@v1.12.1/artifactory/commands/utils/npmcmdutils_test.go (about)

     1  package utils
     2  
     3  import "testing"
     4  
     5  func TestGetRegistry(t *testing.T) {
     6  	var getRegistryTest = []struct {
     7  		repo     string
     8  		url      string
     9  		expected string
    10  	}{
    11  		{"repo", "http://url/art", "http://url/art/api/npm/repo"},
    12  		{"repo", "http://url/art/", "http://url/art/api/npm/repo"},
    13  		{"repo", "", "/api/npm/repo"},
    14  		{"", "http://url/art", "http://url/art/api/npm/"},
    15  	}
    16  
    17  	for _, testCase := range getRegistryTest {
    18  		if getNpmRepositoryUrl(testCase.repo, testCase.url) != testCase.expected {
    19  			t.Errorf("The expected output of getRegistry(\"%s\", \"%s\") is %s. But the actual result is:%s", testCase.repo, testCase.url, testCase.expected, getNpmRepositoryUrl(testCase.repo, testCase.url))
    20  		}
    21  	}
    22  }