@@ -1327,9 +1327,10 @@ func TestGovcCreateRole(t *testing.T) {
13271327func TestGovcGroupExistsFalse (t * testing.T ) {
13281328 ctx := context .Background ()
13291329 _ , g , executable , env := setup (t )
1330- group := "EKSA"
1330+ group := "FakeGroup"
1331+ expectedErr := "govc: ServerFaultCode: The specified principal (FakeGroup@vsphere.local) is invalid.\n Caused by: group FakeGroup doesn't exist or multiple groups same name"
13311332
1332- executable .EXPECT ().ExecuteWithEnv (ctx , env , "sso.group.ls" , group ).Return (* bytes .NewBufferString ("" ), nil )
1333+ executable .EXPECT ().ExecuteWithEnv (ctx , env , "sso.group.ls" , group ).Return (* bytes .NewBufferString ("" ), errors . New ( expectedErr ) )
13331334
13341335 exists , err := g .GroupExists (ctx , group )
13351336 gt := NewWithT (t )
@@ -1341,8 +1342,8 @@ func TestGovcGroupExistsTrue(t *testing.T) {
13411342 ctx := context .Background ()
13421343 _ , g , executable , env := setup (t )
13431344 group := "EKSA"
1344-
1345- executable .EXPECT ().ExecuteWithEnv (ctx , env , "sso.group.ls" , group ).Return (* bytes .NewBufferString (group ), nil )
1345+ // If group exists, govc should give empty response
1346+ executable .EXPECT ().ExecuteWithEnv (ctx , env , "sso.group.ls" , group ).Return (* bytes .NewBufferString ("" ), nil )
13461347
13471348 exists , err := g .GroupExists (ctx , group )
13481349 gt := NewWithT (t )
@@ -1354,8 +1355,7 @@ func TestGovcGroupExistsError(t *testing.T) {
13541355 ctx := context .Background ()
13551356 _ , g , executable , env := setup (t )
13561357 group := "EKSA"
1357-
1358- executable .EXPECT ().ExecuteWithEnv (ctx , env , "sso.group.ls" , group ).Return (* bytes .NewBufferString ("" ), errors .New ("operation failed" ))
1358+ executable .EXPECT ().ExecuteWithEnv (ctx , env , "sso.group.ls" , group ).Return (* bytes .NewBufferString ("" ), errors .New ("unexpected error" ))
13591359
13601360 _ , err := g .GroupExists (ctx , group )
13611361 gt := NewWithT (t )
0 commit comments