github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/internal/prompt/helpers_test.go (about) 1 package prompt 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestInputRequired(t *testing.T) { 10 assert.Error(t, inputRequired(""), "Throws error because value is empty") 11 assert.NoError(t, inputRequired("foo"), "Doesn't throw an error cause value 'foo' is not empty") 12 assert.NoError(t, inputRequired(0), "Doesn't throw an error cause value is '0' not empty") 13 assert.NoError(t, inputRequired(false), "Doesn't throw an error cause value 'false' is not empty") 14 } 15 16 func TestFormatMessageByCols(t *testing.T) { 17 assert.Equal(t, "aa\naa\naa", formatMessageByCols("aaaaaa", 3), "Adds linebreaks at col limit") 18 assert.Equal(t, "a\naa\naa\na", formatMessageByCols("a\naaaaa", 3), "Adds linebreaks at col limit") 19 }