gunk-dev/the-valley

carry_test.go

source8043b5e912d0main's published tip history
687 bytes
1package main
2
3import "testing"
4
5// An answer carries over landings only as far as the change's carry mode
6// allows: same-paths over any, same-class over those that touched none
7// of its classes, exact over none.
8func TestCarryAllows(t *testing.T) {
9 for _, c := range []struct {
10 mode string
11 shared bool
12 want bool
13 }{
14 {"same-paths", false, true},
15 {"same-paths", true, true},
16 {"same-class", false, true},
17 {"same-class", true, false},
18 {"exact", false, false},
19 {"exact", true, false},
20 {"unknown", false, false},
21 } {
22 if got := carryAllows(c.mode, c.shared); got != c.want {
23 t.Errorf("carryAllows(%q, %v) = %v, want %v", c.mode, c.shared, got, c.want)
24 }
25 }
26}