github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/bintray/commands/config_test.go (about) 1 package commands 2 3 import ( 4 "encoding/json" 5 "github.com/jfrog/jfrog-cli-go/utils/config" 6 "github.com/jfrog/jfrog-cli-go/utils/log" 7 "testing" 8 ) 9 10 func TestConfig(t *testing.T) { 11 log.SetDefaultLogger() 12 expected := &config.BintrayDetails{ 13 ApiUrl: "https://api.bintray.com/", 14 DownloadServerUrl: "https://dl.bintray.com/", 15 User: "user", 16 Key: "api-key", 17 DefPackageLicense: "Apache-2.0"} 18 Config(expected, nil, false) 19 details, err := GetConfig() 20 if err != nil { 21 t.Error(err.Error()) 22 } 23 if configStructToString(expected) != configStructToString(details) { 24 t.Error("Unexpected configuration was saved to file. Expected: " + configStructToString(expected) + " Got " + configStructToString(details)) 25 } 26 } 27 28 func configStructToString(config *config.BintrayDetails) string { 29 marshaledStruct, _ := json.Marshal(*config) 30 return string(marshaledStruct) 31 }