Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

core / knotserver / internal_pushoptions_test.go
1.7 kB 57 lines
1package knotserver 2 3import ( 4 "testing" 5 6 "tangled.org/core/knotserver/git" 7) 8 9func TestHasVerboseCIPushOption(t *testing.T) { 10 cases := []struct { 11 name string 12 pushOptions []string 13 want bool 14 }{ 15 {"verbose-ci token", []string{"verbose-ci"}, true}, 16 {"ci-verbose token", []string{"ci-verbose"}, true}, 17 {"verbose token among others", []string{"foo", "ci-verbose", "bar"}, true}, 18 {"skip-ci is not verbose", []string{"skip-ci"}, false}, 19 {"ci-skip is not verbose", []string{"ci-skip"}, false}, 20 {"unrelated token", []string{"whatever"}, false}, 21 {"empty slice", []string{}, false}, 22 {"nil slice", nil, false}, 23 } 24 25 for _, tc := range cases { 26 t.Run(tc.name, func(t *testing.T) { 27 if got := hasVerboseCIPushOption(tc.pushOptions); got != tc.want { 28 t.Errorf("hasVerboseCIPushOption(%v) = %v, want %v", tc.pushOptions, got, tc.want) 29 } 30 }) 31 } 32} 33 34func TestHasSkipCIPushOption(t *testing.T) { 35 cases := []struct { 36 name string 37 pushOptions []string 38 want bool 39 }{ 40 {"skip-ci token", []string{"skip-ci"}, true}, 41 {"ci-skip token", []string{"ci-skip"}, true}, 42 {"skip token among others", []string{"foo", "skip-ci", "bar"}, true}, 43 {"verbose-ci is not skip", []string{"verbose-ci"}, false}, 44 {"ci-verbose is not skip", []string{"ci-verbose"}, false}, 45 {"unrelated token", []string{"whatever"}, false}, 46 {"empty slice", []string{}, false}, 47 {"nil slice", nil, false}, 48 } 49 50 for _, tc := range cases { 51 t.Run(tc.name, func(t *testing.T) { 52 if got := git.HasSkipCIPushOption(tc.pushOptions); got != tc.want { 53 t.Errorf("hasSkipCIPushOption(%v) = %v, want %v", tc.pushOptions, got, tc.want) 54 } 55 }) 56 } 57}