(t *testing.T)
| 712 | } |
| 713 | |
| 714 | func TestParseIntoFile(t *testing.T) { |
| 715 | got := map[string]any{} |
| 716 | input := "name1=path1" |
| 717 | expect := map[string]any{ |
| 718 | "name1": "value1", |
| 719 | } |
| 720 | rs2v := func(rs []rune) (any, error) { |
| 721 | v := string(rs) |
| 722 | if v != "path1" { |
| 723 | t.Errorf("%s: runesToVal: Expected value path1, got %s", input, v) |
| 724 | return "", nil |
| 725 | } |
| 726 | return "value1", nil |
| 727 | } |
| 728 | |
| 729 | if err := ParseIntoFile(input, got, rs2v); err != nil { |
| 730 | t.Fatal(err) |
| 731 | } |
| 732 | |
| 733 | y1, err := yaml.Marshal(expect) |
| 734 | if err != nil { |
| 735 | t.Fatal(err) |
| 736 | } |
| 737 | y2, err := yaml.Marshal(got) |
| 738 | if err != nil { |
| 739 | t.Fatalf("Error serializing parsed value: %s", err) |
| 740 | } |
| 741 | |
| 742 | if string(y1) != string(y2) { |
| 743 | t.Errorf("%s: Expected:\n%s\nGot:\n%s", input, y1, y2) |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | func TestToYAML(t *testing.T) { |
| 748 | // The TestParse does the hard part. We just verify that YAML formatting is |
nothing calls this directly
no test coverage detected
searching dependent graphs…