diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-09-07 15:14:11 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-09-07 15:16:03 -0600 |
commit | 29e710836007c8946d636a68b7dfaea6ee44028b (patch) | |
tree | a1d0866bd844d384d7bade3b24bb237495f2d398 /gopher/gophermap/extended_test.go | |
parent | da5d3607c7e51043f425dac87ac723395e092551 (diff) |
fix loop exit conditions on extended gophermap parsing
Diffstat (limited to 'gopher/gophermap/extended_test.go')
-rw-r--r-- | gopher/gophermap/extended_test.go | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/gopher/gophermap/extended_test.go b/gopher/gophermap/extended_test.go index 2d9e9b1..0c8b647 100644 --- a/gopher/gophermap/extended_test.go +++ b/gopher/gophermap/extended_test.go @@ -15,18 +15,12 @@ func TestExtendedDoc(t *testing.T) { t.Fatal(err) } - source := &bytes.Buffer{} - _, err = io.Copy(source, file) - _ = file.Close() - if err != nil { - t.Fatal(err) - } - - edoc, err := ParseExtended(source, &url.URL{ + edoc, err := ParseExtended(file, &url.URL{ Scheme: "gopher", Host: "localhost.localdomain:70", Path: "/customlist.gophermap", }) + _ = file.Close() if err != nil { t.Fatal(err) } @@ -59,3 +53,39 @@ func TestExtendedDoc(t *testing.T) { t.Fatal("output mismatch") } } + +func TestUptimeOutput(t *testing.T) { + file, err := os.Open("testdata/uptime") + if err != nil { + t.Fatal(err) + } + + edoc, err := ParseExtended(file, &url.URL{ + Scheme: "gopher", + Host: "localhost.localdomain:70", + Path: "/customlist.gophermap", + }) + _ = file.Close() + + doc, _, err := edoc.Compatible("testdata", FileSystemSettings{ + ParseExtended: true, + }) + if err != nil { + t.Fatal(err) + } + got := doc.String() + + file, err = os.Open("testdata/uptime_output.gophermap") + if err != nil { + t.Fatal(err) + } + + expected, err := io.ReadAll(file) + _ = file.Close() + + if string(expected) != got { + fmt.Printf("expected:\n%s", string(expected)) + fmt.Printf("got:\n%s", got) + t.Fatal("output mismatch") + } +} |