This commit is contained in:
Vladimir V Maksimov
2025-12-13 14:46:46 +03:00
parent 5b91fda6c5
commit b400e55f69
7 changed files with 160 additions and 1 deletions

31
load_test.go Normal file
View File

@@ -0,0 +1,31 @@
package config_test
import (
"errors"
"testing"
"git.gm6.ru/icewind/config"
)
type TestObject struct {
Addrs []string `yaml:"addrs"`
Name string `yaml:"name"`
Enabled bool `yaml:"enabled"`
Version string `yaml:"version"`
}
func (s *TestObject) Check() error {
if len(s.Addrs) == 0 {
return errors.New("addrs expected")
}
return nil
}
func TestLoadFromFile(t *testing.T) {
path := "./test-data/config.yaml"
var obj TestObject
if err := config.LoadFromFile(path, &obj); err != nil {
t.Fatal(err)
}
t.Log(obj)
}