AnthoLume/config/config_test.go

38 lines
892 B
Go
Raw Normal View History

2023-10-24 00:18:16 +00:00
package config
import (
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
2023-10-24 00:18:16 +00:00
func TestLoadConfig(t *testing.T) {
conf := Load()
assert.Equal(t, "sqlite", conf.DBType)
2023-10-24 00:18:16 +00:00
}
func TestGetEnvDefault(t *testing.T) {
desiredValue := "def_val"
envDefault := getEnv("DEFAULT_TEST", desiredValue)
2023-10-24 00:18:16 +00:00
assert.Equal(t, desiredValue, envDefault)
2023-10-24 00:18:16 +00:00
}
func TestTrimLowerString(t *testing.T) {
desiredValue := "trimtest"
outputValue := trimLowerString(" trimTest ")
assert.Equal(t, desiredValue, outputValue)
}
func TestPrettyCaller(t *testing.T) {
p, _, _, _ := runtime.Caller(0)
result := runtime.CallersFrames([]uintptr{p})
f, _ := result.Next()
functionName, fileName := prettyCaller(&f)
assert.Equal(t, "TestPrettyCaller", functionName, "should have current function name")
assert.Equal(t, "config/config_test.go@30", fileName, "should have current file path and line number")
2023-10-24 00:18:16 +00:00
}