Merge pull request #1 from taigrr/cd/update-go-deps-and-tests

chore: update Go 1.26.0, deps, and test coverage to 97%
This commit is contained in:
2026-02-24 02:08:49 -05:00
committed by GitHub
3 changed files with 126 additions and 4 deletions

4
go.mod
View File

@@ -1,8 +1,8 @@
module github.com/taigrr/jety module github.com/taigrr/jety
go 1.25.5 go 1.26.0
require ( require (
github.com/BurntSushi/toml v1.3.2 github.com/BurntSushi/toml v1.6.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )

4
go.sum
View File

@@ -1,5 +1,5 @@
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@@ -1064,6 +1064,128 @@ enabled = false
} }
} }
func TestPackageLevelGetIntSlice(t *testing.T) {
defaultConfigManager = NewConfigManager()
Set("nums", []int{1, 2, 3})
got := GetIntSlice("nums")
if len(got) != 3 || got[0] != 1 {
t.Errorf("GetIntSlice() = %v, want [1 2 3]", got)
}
}
func TestPackageLevelSetConfigName(t *testing.T) {
defaultConfigManager = NewConfigManager()
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "app.json"), []byte(`{"port": 1234}`), 0o644); err != nil {
t.Fatal(err)
}
SetConfigName("app")
defaultConfigManager.SetConfigDir(dir)
if err := SetConfigType("json"); err != nil {
t.Fatal(err)
}
if err := ReadInConfig(); err != nil {
t.Fatal(err)
}
if got := GetInt("port"); got != 1234 {
t.Errorf("GetInt(port) = %d, want 1234", got)
}
}
func TestPackageLevelSetEnvPrefix(t *testing.T) {
defaultConfigManager = NewConfigManager()
SetEnvPrefix("JETY_TEST_")
if defaultConfigManager.envPrefix != "JETY_TEST_" {
t.Errorf("envPrefix = %q, want %q", defaultConfigManager.envPrefix, "JETY_TEST_")
}
}
func TestPackageLevelWriteConfig(t *testing.T) {
defaultConfigManager = NewConfigManager()
dir := t.TempDir()
f := filepath.Join(dir, "out.json")
SetConfigFile(f)
if err := SetConfigType("json"); err != nil {
t.Fatal(err)
}
Set("key", "value")
if err := WriteConfig(); err != nil {
t.Fatal(err)
}
data, _ := os.ReadFile(f)
if len(data) == 0 {
t.Error("WriteConfig produced empty file")
}
}
func TestPackageLevelGetStringMap(t *testing.T) {
defaultConfigManager = NewConfigManager()
Set("m", map[string]any{"a": 1})
got := GetStringMap("m")
if got == nil || got["a"] != 1 {
t.Errorf("GetStringMap() = %v", got)
}
}
func TestPackageLevelGetStringSlice(t *testing.T) {
defaultConfigManager = NewConfigManager()
Set("s", []string{"a", "b"})
got := GetStringSlice("s")
if len(got) != 2 || got[0] != "a" {
t.Errorf("GetStringSlice() = %v", got)
}
}
func TestGetStringNonStringValue(t *testing.T) {
cm := NewConfigManager()
cm.Set("num", 42)
if got := cm.GetString("num"); got != "42" {
t.Errorf("GetString(num) = %q, want %q", got, "42")
}
}
func TestGetIntInt64(t *testing.T) {
cm := NewConfigManager()
cm.Set("key", int64(999))
if got := cm.GetInt("key"); got != 999 {
t.Errorf("GetInt(int64) = %d, want 999", got)
}
}
func TestGetIntUnknownType(t *testing.T) {
cm := NewConfigManager()
cm.Set("key", struct{}{})
if got := cm.GetInt("key"); got != 0 {
t.Errorf("GetInt(struct) = %d, want 0", got)
}
}
func TestGetIntSliceInt64Values(t *testing.T) {
cm := NewConfigManager()
cm.Set("key", []any{int64(10), int64(20)})
got := cm.GetIntSlice("key")
if len(got) != 2 || got[0] != 10 || got[1] != 20 {
t.Errorf("GetIntSlice(int64) = %v, want [10 20]", got)
}
}
func TestGetIntSliceNonSlice(t *testing.T) {
cm := NewConfigManager()
cm.Set("key", "notaslice")
if got := cm.GetIntSlice("key"); got != nil {
t.Errorf("GetIntSlice(string) = %v, want nil", got)
}
}
func TestGetIntSliceUnknownInnerType(t *testing.T) {
cm := NewConfigManager()
cm.Set("key", []any{struct{}{}, true})
got := cm.GetIntSlice("key")
if len(got) != 0 {
t.Errorf("GetIntSlice(unknown types) = %v, want []", got)
}
}
func TestDeeplyNestedWriteConfig(t *testing.T) { func TestDeeplyNestedWriteConfig(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()