diff --git a/CHANGELOG.md b/CHANGELOG.md index 106f0a8..475de07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,11 @@ All notable changes to Jarl are documented here. The format follows ### Fixed +- `jarl zone show` for a reverse zone printed only "and 1 more" under + "Other views:" when the server was older than the CLI (0.6.1-rc.2 + sends the count but not the addresses). It now prints just the count + line then. + - The statistics' "Busiest times" grid drew hours without data taller than the others (they picked up the page's padding for empty messages). diff --git a/cmd/jarl/ptrfills_test.go b/cmd/jarl/ptrfills_test.go new file mode 100644 index 0000000..460071b --- /dev/null +++ b/cmd/jarl/ptrfills_test.go @@ -0,0 +1,25 @@ +package main + +import ( + "bytes" + "strings" + "testing" + + "jarl/internal/api" +) + +func TestPrintPTRFills(t *testing.T) { + var b bytes.Buffer + printPTRFills(&b, []api.PTRFill{{Address: "10.0.10.20", Target: "nextcloud.adbraun.lol.", From: "internal"}}, 3) + out := b.String() + if !strings.Contains(out, "10.0.10.20 -> nextcloud.adbraun.lol (view internal)") || !strings.Contains(out, "and 2 more") { + t.Errorf("listed fills:\n%s", out) + } + + // An older server sends the count without the list. + b.Reset() + printPTRFills(&b, nil, 1) + if b.Len() != 0 { + t.Errorf("no list from the server printed %q, want nothing", b.String()) + } +} diff --git a/cmd/jarl/zones.go b/cmd/jarl/zones.go index 8908859..014fa4a 100644 --- a/cmd/jarl/zones.go +++ b/cmd/jarl/zones.go @@ -1183,8 +1183,13 @@ func terminalWidth() int { } // printPTRFills lists PTR records a reverse zone lacks under zone show's -// line about them: address -> name, and the view the name is from. +// line about them: address -> name, and the view the name is from. A server +// older than the CLI may send the count without the list; then nothing is +// listed, rather than "and N more" under no addresses. func printPTRFills(w io.Writer, fills []api.PTRFill, total int) { + if len(fills) == 0 { + return + } for _, f := range fills { from := "" if f.From != "" {