github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/cli-plugins/hooks/printer_test.go (about) 1 package hooks 2 3 import ( 4 "bytes" 5 "testing" 6 7 "github.com/morikuni/aec" 8 "gotest.tools/v3/assert" 9 ) 10 11 func TestPrintHookMessages(t *testing.T) { 12 testCases := []struct { 13 messages []string 14 expectedOutput string 15 }{ 16 { 17 messages: []string{}, 18 expectedOutput: "", 19 }, 20 { 21 messages: []string{"Bork!"}, 22 expectedOutput: aec.Bold.Apply("\nWhat's next:") + "\n" + 23 " Bork!\n", 24 }, 25 { 26 messages: []string{"Foo", "bar"}, 27 expectedOutput: aec.Bold.Apply("\nWhat's next:") + "\n" + 28 " Foo\n" + 29 " bar\n", 30 }, 31 } 32 33 for _, tc := range testCases { 34 w := bytes.Buffer{} 35 PrintNextSteps(&w, tc.messages) 36 assert.Equal(t, w.String(), tc.expectedOutput) 37 } 38 }