@@ -63,6 +63,49 @@ func TestUpdateTenantCmd(t *testing.T) {
6363 assert .Equal (t , "standalone" , tenantData .AllowedClusters [0 ])
6464}
6565
66+ func TestUpdateTenantPartial (t * testing.T ) {
67+ args := []string {"create" , "--admin-roles" , "initial-role" , "--allowed-clusters" , "standalone" , "update-tenant-partial" }
68+ _ , execErr , _ , _ := TestTenantCommands (createTenantCmd , args )
69+ assert .Nil (t , execErr )
70+
71+ args = []string {"update" , "--allowed-clusters" , "standalone" , "update-tenant-partial" }
72+ _ , execErr , _ , _ = TestTenantCommands (UpdateTenantCmd , args )
73+ assert .Nil (t , execErr )
74+
75+ args = []string {"get" , "update-tenant-partial" }
76+ out , execErr , _ , _ := TestTenantCommands (getTenantCmd , args )
77+ assert .Nil (t , execErr )
78+
79+ var tenantData utils.TenantData
80+ err := json .Unmarshal (out .Bytes (), & tenantData )
81+ if err != nil {
82+ t .Fatal (err )
83+ }
84+
85+ assert .Equal (t , 1 , len (tenantData .AdminRoles ))
86+ assert .Equal (t , "initial-role" , tenantData .AdminRoles [0 ])
87+ assert .Equal (t , 1 , len (tenantData .AllowedClusters ))
88+ assert .Equal (t , "standalone" , tenantData .AllowedClusters [0 ])
89+
90+ args = []string {"update" , "--admin-roles" , "updated-role" , "update-tenant-partial" }
91+ _ , execErr , _ , _ = TestTenantCommands (UpdateTenantCmd , args )
92+ assert .Nil (t , execErr )
93+
94+ args = []string {"get" , "update-tenant-partial" }
95+ out , execErr , _ , _ = TestTenantCommands (getTenantCmd , args )
96+ assert .Nil (t , execErr )
97+
98+ err = json .Unmarshal (out .Bytes (), & tenantData )
99+ if err != nil {
100+ t .Fatal (err )
101+ }
102+
103+ assert .Equal (t , 1 , len (tenantData .AdminRoles ))
104+ assert .Equal (t , "updated-role" , tenantData .AdminRoles [0 ])
105+ assert .Equal (t , 1 , len (tenantData .AllowedClusters ))
106+ assert .Equal (t , "standalone" , tenantData .AllowedClusters [0 ])
107+ }
108+
66109func TestUpdateArgsError (t * testing.T ) {
67110 args := []string {"update" }
68111 _ , _ , nameErr , _ := TestTenantCommands (UpdateTenantCmd , args )
0 commit comments