|
|
@ -449,6 +449,39 @@ func TestParseIntoString(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestParseFile(t *testing.T) {
|
|
|
|
|
|
|
|
input := "name1=path1"
|
|
|
|
|
|
|
|
expect := map[string]interface{}{
|
|
|
|
|
|
|
|
"name1": "value1",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rs2v := func(rs []rune) (interface{}, error) {
|
|
|
|
|
|
|
|
v := string(rs)
|
|
|
|
|
|
|
|
if v != "path1" {
|
|
|
|
|
|
|
|
t.Errorf("%s: runesToVal: Expected value path1, got %s", input, v)
|
|
|
|
|
|
|
|
return "", nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "value1", nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
got, err := ParseFile(input, rs2v)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
y1, err := yaml.Marshal(expect)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
y2, err := yaml.Marshal(got)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatalf("Error serializing parsed value: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if string(y1) != string(y2) {
|
|
|
|
|
|
|
|
t.Errorf("%s: Expected:\n%s\nGot:\n%s", input, y1, y2)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestParseIntoFile(t *testing.T) {
|
|
|
|
func TestParseIntoFile(t *testing.T) {
|
|
|
|
got := map[string]interface{}{}
|
|
|
|
got := map[string]interface{}{}
|
|
|
|
input := "name1=path1"
|
|
|
|
input := "name1=path1"
|
|
|
|