|
@@ -0,0 +1,64 @@
|
|
|
+package config
|
|
|
+
|
|
|
+import "testing"
|
|
|
+
|
|
|
+func TestSaveConfig(t *testing.T) {
|
|
|
+ conf := &Config{}
|
|
|
+ id := 12245
|
|
|
+ conf.Id = &id
|
|
|
+ conf.Net.Listen = "tcp:localhost:12345"
|
|
|
+ conf.Net.As = "tcp:10.0.0.1:12345"
|
|
|
+ conf.Net.Command = "unix:/tmp/bdjncl"
|
|
|
+ in := []Io{{"video", "application/mod"}}
|
|
|
+ out := []Io{{"result", "application/json"}}
|
|
|
+ sk := Skill{"test", in, out}
|
|
|
+ sk2 := Skill{"test2", in, out}
|
|
|
+
|
|
|
+ conf.Peers = []Peer{
|
|
|
+ Peer{As: "tcp:localhost:12346", Skills: []Skill{sk}},
|
|
|
+ Peer{As: "tcp:localhost:12347", Skills: []Skill{sk}},
|
|
|
+ }
|
|
|
+
|
|
|
+ st0 := Step{"s3-download", `"$input_video"`}
|
|
|
+ st1 := Step{"sh", `/bin/echo "$input_video" "$output_result"`}
|
|
|
+
|
|
|
+ conf.Jobs = []Job{
|
|
|
+ Job{sk, []Step{st0, st1}},
|
|
|
+ Job{sk2, []Step{st1, st0}},
|
|
|
+ }
|
|
|
+
|
|
|
+ conf.States = []State{
|
|
|
+ State{"test", "running", 1},
|
|
|
+ }
|
|
|
+ err := conf.SaveTomlFileName("testdata/config.toml")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Error saving: %s", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ err = conf.SaveYamlFileName("testdata/config.yaml")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Error saving: %s", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ dat, err := LoadYamlFileName("testdata/config.yaml")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Error loading: %s", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ t.Logf("Encoded: %v", conf)
|
|
|
+ t.Logf("Loaded: %v", dat)
|
|
|
+
|
|
|
+ err = conf.SaveHclFileName("testdata/config.hcl")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Error saving: %s", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ dat, err = LoadHclFileName("testdata/config.hcl")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Error loading: %s", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ t.Logf("Encoded: %v", conf)
|
|
|
+ t.Logf("Loaded: %v", dat)
|
|
|
+
|
|
|
+}
|