Merge pull request #7365 from fenggw-fnst/mybranch

Add corresponding unit test to the function in parser.go
pull/7617/head
Martin Hickey 4 years ago committed by GitHub
commit 0c9e99dce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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) {
got := map[string]interface{}{}
input := "name1=path1"

Loading…
Cancel
Save