diff options
Diffstat (limited to 'cmd/krino/review_test.go')
| -rw-r--r-- | cmd/krino/review_test.go | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/cmd/krino/review_test.go b/cmd/krino/review_test.go index 193a191..6bf5ea7 100644 --- a/cmd/krino/review_test.go +++ b/cmd/krino/review_test.go @@ -20,7 +20,7 @@ func chains(rels ...string) []plan.Chain { func TestChoosePerFile(t *testing.T) { // c enters per-file mode, then y n y for three files. - approved, action, err := reviewChains(strings.NewReader("cyny"), new(strings.Builder), chains("a", "b", "c"), "") + approved, action, err := reviewChains(strings.NewReader("cyny"), new(strings.Builder), chains("a", "b", "c"), "", palette{}) if err != nil { t.Fatal(err) } @@ -33,11 +33,11 @@ func TestChoosePerFile(t *testing.T) { } func TestApplyAllAndSkip(t *testing.T) { - approved, action, _ := reviewChains(strings.NewReader("a"), new(strings.Builder), chains("a", "b"), "") + approved, action, _ := reviewChains(strings.NewReader("a"), new(strings.Builder), chains("a", "b"), "", palette{}) if action != 'a' || len(approved) != 2 { t.Errorf("[a] = %q %v; want every file approved", action, approved) } - approved, action, _ = reviewChains(strings.NewReader("s"), new(strings.Builder), chains("a", "b"), "") + approved, action, _ = reviewChains(strings.NewReader("s"), new(strings.Builder), chains("a", "b"), "", palette{}) if action != 's' || len(approved) != 0 { t.Errorf("[s] = %q %v; want nothing approved", action, approved) } @@ -45,7 +45,7 @@ func TestApplyAllAndSkip(t *testing.T) { func TestPerFileDoneStopsAsking(t *testing.T) { // c, y for the first, then d: apply what was chosen so far. - approved, _, _ := reviewChains(strings.NewReader("cyd"), new(strings.Builder), chains("a", "b", "c"), "") + approved, _, _ := reviewChains(strings.NewReader("cyd"), new(strings.Builder), chains("a", "b", "c"), "", palette{}) if !approved["a"] || approved["b"] || approved["c"] { t.Errorf("approved = %v; want only a", approved) } @@ -57,7 +57,7 @@ func TestPerFileDoneStopsAsking(t *testing.T) { // for the directory-level menu (spec §8.2's [q]), and discards even a file // already marked yes. func TestPerFileQuitAppliesNothing(t *testing.T) { - approved, action, err := reviewChains(strings.NewReader("cyq"), new(strings.Builder), chains("a", "b"), "") + approved, action, err := reviewChains(strings.NewReader("cyq"), new(strings.Builder), chains("a", "b"), "", palette{}) if err != nil { t.Fatal(err) } @@ -72,7 +72,7 @@ func TestPerFileQuitAppliesNothing(t *testing.T) { // TestPerFileYesToAllRemaining: spec §8.3's [a] mid-review approves the // current file and every remaining one without asking again. func TestPerFileYesToAllRemaining(t *testing.T) { - approved, action, err := reviewChains(strings.NewReader("ca"), new(strings.Builder), chains("a", "b", "c"), "") + approved, action, err := reviewChains(strings.NewReader("ca"), new(strings.Builder), chains("a", "b", "c"), "", palette{}) if err != nil { t.Fatal(err) } @@ -86,7 +86,7 @@ func TestPerFileYesToAllRemaining(t *testing.T) { // same prompt is read again. func TestInvalidKeyReprompts(t *testing.T) { out := new(strings.Builder) - approved, action, err := reviewChains(strings.NewReader("zs"), out, chains("a"), "") + approved, action, err := reviewChains(strings.NewReader("zs"), out, chains("a"), "", palette{}) if err != nil { t.Fatal(err) } @@ -113,7 +113,7 @@ func TestPerFileDestinationIsRootRelative(t *testing.T) { {File: scan.File{Rel: "outside.txt"}, Steps: []plan.Step{{Kind: plan.Move, Dst: "/home/x/backup/outside.txt"}}}, } out := new(strings.Builder) - if _, _, err := reviewChains(strings.NewReader("cyy"), out, cs, root); err != nil { + if _, _, err := reviewChains(strings.NewReader("cyy"), out, cs, root, palette{}); err != nil { t.Fatal(err) } text := out.String() @@ -124,21 +124,3 @@ func TestPerFileDestinationIsRootRelative(t *testing.T) { t.Errorf("destination outside root should be ~-abbreviated:\n%s", text) } } - -// TestNoColourEscapeFromColourFalse pins Ruling 7's safety guarantee at the -// unit that actually decides it: with colour off, colourDeletePermanently -// must not alter the text at all, and with colour on it must add an escape -// around exactly the one marker spec §8.2 singles out for emphasis. -func TestColourDeletePermanently(t *testing.T) { - plain := " 4 setup-1.2.deb DELETE permanently old-pkgs age 94d\n" - if got := colourDeletePermanently(plain, false); got != plain { - t.Errorf("colour=false must leave the text untouched:\n%q", got) - } - got := colourDeletePermanently(plain, true) - if !strings.Contains(got, "\x1b[") { - t.Errorf("colour=true should add an escape sequence:\n%q", got) - } - if !strings.Contains(got, "DELETE permanently") { - t.Errorf("colour=true should not remove the marker text itself:\n%q", got) - } -} |
