internal/control/search_test.go

v1.43.0
gitbay/internal/control/search_test.go history · blame · raw

23 lines · 671 bytes

 1package control
 2
 3import (
 4	"bytes"
 5	"testing"
 6)
 7
 8// Plain output has no header to align to, so a repo row stays 3 cells —
 9// bytes must not change from before the terminal fix.
10func TestSearchTablePlainRepoRowIsThreeCells(t *testing.T) {
11	results := []SearchResult{
12		{Kind: "repo", Repo: "alice/webapp", Title: "a web application"},
13		{Kind: "issue", Repo: "alice/webapp", Number: 4, Title: "memory leak", State: "open"},
14	}
15	var b bytes.Buffer
16	writeSearchTable(&Ctx{}, &b, results)
17
18	want := "repo\talice/webapp\ta web application\n" +
19		"issue\talice/webapp#4\topen\tmemory leak\n"
20	if b.String() != want {
21		t.Errorf("plain:\n%q\nwant\n%q", b.String(), want)
22	}
23}