(t *testing.T)
| 97 | } |
| 98 | |
| 99 | func TestTable(t *testing.T) { |
| 100 | doc := ` |
| 101 | title: "Moby Dick" |
| 102 | chapter: |
| 103 | one: |
| 104 | title: "Loomings" |
| 105 | two: |
| 106 | title: "The Carpet-Bag" |
| 107 | three: |
| 108 | title: "The Spouter Inn" |
| 109 | ` |
| 110 | d, err := ReadValues([]byte(doc)) |
| 111 | if err != nil { |
| 112 | t.Fatalf("Failed to parse the White Whale: %s", err) |
| 113 | } |
| 114 | |
| 115 | if _, err := d.Table("title"); err == nil { |
| 116 | t.Fatal("Title is not a table.") |
| 117 | } |
| 118 | |
| 119 | if _, err := d.Table("chapter"); err != nil { |
| 120 | t.Fatalf("Failed to get the chapter table: %s\n%v", err, d) |
| 121 | } |
| 122 | |
| 123 | if v, err := d.Table("chapter.one"); err != nil { |
| 124 | t.Errorf("Failed to get chapter.one: %s", err) |
| 125 | } else if v["title"] != "Loomings" { |
| 126 | t.Errorf("Unexpected title: %s", v["title"]) |
| 127 | } |
| 128 | |
| 129 | if _, err := d.Table("chapter.three"); err != nil { |
| 130 | t.Errorf("Chapter three is missing: %s\n%v", err, d) |
| 131 | } |
| 132 | |
| 133 | if _, err := d.Table("chapter.OneHundredThirtySix"); err == nil { |
| 134 | t.Error("I think you mean 'Epilogue'") |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | func matchValues(t *testing.T, data map[string]any) { |
| 139 | t.Helper() |
nothing calls this directly
no test coverage detected
searching dependent graphs…