github.com/jfrog/jfrog-cli-core/v2@v2.52.0/general/utils_test.go (about)

     1  package general
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"testing"
     6  )
     7  
     8  type deduceServerIdTest struct {
     9  	url              string
    10  	expectedServerID string
    11  }
    12  
    13  func TestDeduceServerId(t *testing.T) {
    14  	testCases := []deduceServerIdTest{
    15  		{"http://localhost:8082/", "localhost"},
    16  		{"https://platform.jfrog.io/", "platform"},
    17  		{"http://127.0.0.1:8082/", defaultServerId},
    18  	}
    19  
    20  	for _, testCase := range testCases {
    21  		t.Run(testCase.url, func(t *testing.T) {
    22  			serverId, err := deduceServerId(testCase.url)
    23  			assert.NoError(t, err)
    24  			assert.Equal(t, testCase.expectedServerID, serverId)
    25  		})
    26  	}
    27  }