@@ -10,6 +10,7 @@ import (
1010
1111 "github.com/kernel/cli/pkg/create"
1212 "github.com/pterm/pterm"
13+ "github.com/spf13/cobra"
1314 "github.com/stretchr/testify/assert"
1415 "github.com/stretchr/testify/require"
1516)
@@ -93,6 +94,61 @@ func TestCreateCommand(t *testing.T) {
9394 }
9495}
9596
97+ func TestRunCreateApp_DoesNotWrapPromptErrors (t * testing.T ) {
98+ tests := []struct {
99+ name string
100+ flagValues map [string ]string
101+ expectedContains string
102+ unexpectedWrap string
103+ }{
104+ {
105+ name : "missing app name returns direct prompt error" ,
106+ flagValues : map [string ]string {},
107+ expectedContains : "cannot prompt for app name" ,
108+ unexpectedWrap : "failed to get app name:" ,
109+ },
110+ {
111+ name : "invalid language returns direct validation error" ,
112+ flagValues : map [string ]string {
113+ "name" : "my-app" ,
114+ // template is intentionally omitted because language validation fails first.
115+ "language" : "ruby" ,
116+ },
117+ expectedContains : "invalid --language 'ruby'" ,
118+ unexpectedWrap : "failed to get language:" ,
119+ },
120+ {
121+ name : "invalid template returns direct validation error" ,
122+ flagValues : map [string ]string {
123+ "name" : "my-app" ,
124+ "language" : "typescript" ,
125+ "template" : "nonexistent-template" ,
126+ },
127+ expectedContains : "invalid --template 'nonexistent-template'" ,
128+ unexpectedWrap : "failed to get template:" ,
129+ },
130+ }
131+
132+ for _ , tt := range tests {
133+ t .Run (tt .name , func (t * testing.T ) {
134+ cmd := & cobra.Command {}
135+ cmd .Flags ().String ("name" , "" , "" )
136+ cmd .Flags ().String ("language" , "" , "" )
137+ cmd .Flags ().String ("template" , "" , "" )
138+ cmd .Flags ().Bool ("yes" , false , "" )
139+
140+ for flag , value := range tt .flagValues {
141+ require .NoError (t , cmd .Flags ().Set (flag , value ))
142+ }
143+
144+ err := runCreateApp (cmd , nil )
145+ require .Error (t , err )
146+ assert .Contains (t , err .Error (), tt .expectedContains )
147+ assert .NotContains (t , err .Error (), tt .unexpectedWrap )
148+ })
149+ }
150+ }
151+
96152// TestAllTemplatesWithDependencies tests all available templates and verifies dependencies are installed
97153func TestAllTemplatesWithDependencies (t * testing.T ) {
98154 if testing .Short () {
0 commit comments