Skip to content

Commit

Permalink
test: fix config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avirtopeanu-ionos committed Dec 4, 2024
1 parent 6784631 commit 4f57fa4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,25 @@ func TestGetServerUrl(t *testing.T) {
expectedServerUrl: "http://flag.url",
},
{
name: "Flag value is DNS default, Env value is used",
name: "Flag value is DNS Default, return flag value",
flagVal: "dns.de-fra.ionos.com",
envVal: "http://env.url",
cfgVal: "http://cfg.url",
expectedServerUrl: "http://env.url",
expectedServerUrl: "dns.de-fra.ionos.com",
},
{
name: "All values are DNS default or not set, return empty string",
name: "Flag value is DNS default, all other empty, return flag value",
flagVal: "dns.de-fra.ionos.com",
envVal: "",
cfgVal: "",
expectedServerUrl: "",
expectedServerUrl: "dns.de-fra.ionos.com",
},
{
name: "Flag value is empty, env and cfg set, return env value",
flagVal: "",
envVal: "dns.de-fra.ionos.com",
cfgVal: "dns.de-txl.ionos.com",
expectedServerUrl: "dns.de-fra.ionos.com",
},
{
name: "Explicit flag URL is returned",
Expand All @@ -244,6 +251,13 @@ func TestGetServerUrl(t *testing.T) {
cfgVal: "",
expectedServerUrl: constants.DefaultApiURL,
},
{
name: "CFG value is preferred over defaults",
flagVal: "",
envVal: "",
cfgVal: "cfg-url",
expectedServerUrl: "cfg-url",
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 4f57fa4

Please sign in to comment.