Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
package envtool
import (
"os"
"strconv"
"testing"
"fiskerinc.com/modules/testhelper"
)
var defaultValue = "DEFAULT_VALUE"
var existingValue = "EXISTING_VALUE"
var defaultInt = 0
var existingInt = 1
var defaultBool = false
var existingBool = true
func TestGetEnvDefaultValue(t *testing.T) {
got := GetEnv("NON_EXISTING", defaultValue)
if got != defaultValue {
t.Errorf(testhelper.TestErrorTemplate, "Default value", defaultValue, got)
}
}
func TestGetEnvExistingValue(t *testing.T) {
const envName = "EXISTING"
os.Setenv(envName, existingValue)
got := GetEnv(envName, defaultValue)
if got != existingValue {
t.Errorf(testhelper.TestErrorTemplate, "Existing value", existingValue, got)
}
}
func TestGetEnvIntDefaultValue(t *testing.T) {
got := GetEnvInt("NON_EXISTING", defaultInt)
if got != defaultInt {
t.Errorf(testhelper.TestErrorTemplate, "Default value", defaultInt, got)
}
}
func TestGetEnvIntExistingValue(t *testing.T) {
const envName = "EXISTING"
os.Setenv(envName, strconv.Itoa(existingInt))
got := GetEnvInt(envName, defaultInt)
if got != existingInt {
t.Errorf(testhelper.TestErrorTemplate, "Existing value", existingInt, got)
}
}
func TestGetEnvBoolDefaultValue(t *testing.T) {
got := GetEnvBool("NON_EXISTING", defaultBool)
if got != defaultBool {
t.Errorf(testhelper.TestErrorTemplate, "Default Value", defaultBool, got)
}
}
func TestGetEnvBoolExistingValue(t *testing.T) {
const envName = "EXISTING"
os.Setenv(envName, strconv.FormatBool(existingBool))
got := GetEnvBool(envName, defaultBool)
if got != existingBool {
t.Errorf(testhelper.TestErrorTemplate, "Default Value", existingBool, got)
}
}