package index
import "testing"
// A line note is written and read back by the same two functions, so
// the header can only have one dialect; anything else is a remark.
func TestALineNoteRoundTrips(t *testing.T) {
n := LineNote{File: "internal/web/web.go", Side: "new", Line: 2251, At: "8a0ba3d4805e"}
body := FormatLineNote(n, "Record this before the tickets close.\n\nSecond paragraph.")
got, prose, ok := ParseLineNote(body)
if !ok || got != n {
t.Fatalf("FAIL: read back %+v ok=%v from %q", got, ok, body)
}
if prose != "Record this before the tickets close.\n\nSecond paragraph." {
t.Errorf("FAIL: prose %q", prose)
}
for _, other := range []string{
"just a remark",
"zit-line: 1\nfile: a.go\nside: sideways\nline: 3\n\nbad side",
"zit-line: 1\nfile: a.go\nside: new\nline: zero\n\nbad line",
"zit-landing: 1\nbranch: x\n\nthe opener",
"zit-line: 1\nfile: a.go\nside: new\nline: 3\nat: NOT-HEX\n\nbad at",
} {
if _, _, ok := ParseLineNote(other); ok {
t.Errorf("FAIL: %q read as a line note", other)
}
}
}