@@ -90,6 +90,54 @@ func TestAppsListCmd(t *testing.T) {
9090 }
9191}
9292
93+ func TestAppsCreateCmd (t * testing.T ) {
94+ tests := []struct {
95+ name string
96+ args []string
97+ expectedError string
98+ }{
99+ {
100+ name : "Resource Server - resource-server-identifier is empty string" ,
101+ args : []string {
102+ "--name" , "My Resource Server App" ,
103+ "--type" , "resource_server" ,
104+ "--resource-server-identifier" , "" ,
105+ },
106+ expectedError : "resource-server-identifier cannot be empty for resource_server app type" ,
107+ },
108+ {
109+ name : "Resource Server - resource-server-identifier is whitespace only" ,
110+ args : []string {
111+ "--name" , "My Resource Server App" ,
112+ "--type" , "resource_server" ,
113+ "--resource-server-identifier" , " " ,
114+ },
115+ expectedError : "resource-server-identifier cannot be empty for resource_server app type" ,
116+ },
117+ {
118+ name : "Resource Server - resource-server-identifier is tab/newline" ,
119+ args : []string {
120+ "--name" , "My Resource Server App" ,
121+ "--type" , "resource_server" ,
122+ "--resource-server-identifier" , "\t \n " ,
123+ },
124+ expectedError : "resource-server-identifier cannot be empty for resource_server app type" ,
125+ },
126+ }
127+
128+ for _ , test := range tests {
129+ t .Run (test .name , func (t * testing.T ) {
130+ cli := & cli {}
131+ cli .noInput = true // Non-interactive mode.
132+ cmd := createAppCmd (cli )
133+ cmd .SetArgs (test .args )
134+ err := cmd .Execute ()
135+
136+ assert .EqualError (t , err , test .expectedError )
137+ })
138+ }
139+ }
140+
93141func TestFormatAppSettingsPath (t * testing.T ) {
94142 assert .Empty (t , formatAppSettingsPath ("" ))
95143 assert .Equal (t , "applications/app-id-1/settings" , formatAppSettingsPath ("app-id-1" ))
0 commit comments