github.com/jfrog/jfrog-cli-core/v2@v2.51.0/utils/dependencies/utils_test.go (about) 1 package dependencies 2 3 import ( 4 "testing" 5 6 "github.com/jfrog/jfrog-cli-core/v2/utils/config" 7 "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestGetFullRemoteRepoPath(t *testing.T) { 12 // Test cases 13 tests := []struct { 14 repoName string 15 remoteEnv string 16 downloadPath string 17 expectedPath string 18 }{ 19 { 20 repoName: "my-repo", 21 remoteEnv: coreutils.DeprecatedExtractorsRemoteEnv, 22 downloadPath: "path/to/file", 23 expectedPath: "my-repo/path/to/file", 24 }, 25 { 26 repoName: "my-repo", 27 remoteEnv: coreutils.ReleasesRemoteEnv, 28 downloadPath: "path/to/file", 29 expectedPath: "my-repo/artifactory/oss-release-local/path/to/file", 30 }, 31 } 32 33 // Execute the tests 34 for _, test := range tests { 35 actualPath := getFullExtractorsPathInArtifactory(test.repoName, test.remoteEnv, test.downloadPath) 36 assert.Equal(t, test.expectedPath, actualPath) 37 } 38 } 39 40 func TestCreateHttpClient(t *testing.T) { 41 serverDetails := &config.ServerDetails{ 42 Url: "https://acme.jfrog.io", 43 User: "elmar", 44 Password: "Egghead", 45 } 46 httpClient, httpClientDetails, err := CreateHttpClient(serverDetails) 47 assert.NoError(t, err) 48 assert.NotNil(t, httpClient) 49 assert.NotNil(t, httpClientDetails) 50 51 assert.Equal(t, "elmar", httpClientDetails.User) 52 assert.Equal(t, "Egghead", httpClientDetails.Password) 53 }