alpha
This commit is contained in:
31
load_test.go
Normal file
31
load_test.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user