github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/scripts/internal/workflow-controllers/print_test.go (about) 1 package wc 2 3 import "testing" 4 5 func Test_sprint(t *testing.T) { 6 type args struct { 7 depth int 8 msg string 9 args []interface{} 10 } 11 tests := []struct { 12 name string 13 args args 14 want string 15 }{ 16 { 17 name: "Hello world depth 0", 18 args: args{ 19 depth: 0, 20 msg: "Hello world", 21 }, 22 want: "Hello world", 23 }, 24 { 25 name: "Hello world depth 1", 26 args: args{ 27 depth: 1, 28 msg: "Hello world", 29 }, 30 want: " |- Hello world", 31 }, 32 { 33 name: "Hello world depth 1 multi line", 34 args: args{ 35 depth: 1, 36 msg: "Hello \nworld\n!", 37 }, 38 want: " |- Hello \n world\n !", 39 }, 40 { 41 name: "Hello world depth 1 multi line in args", 42 args: args{ 43 depth: 1, 44 msg: "%s", 45 args: []interface{}{"Hello \nworld\n!"}, 46 }, 47 want: " |- Hello \n world\n !", 48 }, 49 } 50 for _, tt := range tests { 51 t.Run(tt.name, func(t *testing.T) { 52 if got := sprint(tt.args.depth, tt.args.msg, tt.args.args...); got != tt.want { 53 t.Errorf("sprint() = '%v', want '%v'", got, tt.want) 54 } 55 }) 56 } 57 }