From 4f57fa4abb454d3c48941e2b08315b242ae9a1ee Mon Sep 17 00:00:00 2001 From: Alexandru Claudius Virtopeanu Date: Wed, 4 Dec 2024 17:31:20 +0200 Subject: [PATCH] test: fix config tests --- internal/config/config_test.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index e0566158c..89dc8a5de 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -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", @@ -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 {