diff options
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") + } +} |