Skip to content

Commit

Permalink
fix ocs unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Dec 7, 2021
1 parent 505776b commit a0eac80
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ocs/pkg/server/http/svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,22 @@ func assertUsersSame(t *testing.T, expected, actual User, quotaAvailable bool) {
}
}

func findAccount(t *testing.T, username string) (*accountsProto.Account, error) {
cl := accountsProto.NewAccountsService("com.owncloud.api.accounts", service.Client())

req := &accountsProto.ListAccountsRequest{
Query: "preferred_name eq '" + username + "'",
}
res, err := cl.ListAccounts(context.Background(), req)
if err != nil {
return nil, err
}
if len(res.Accounts) == 0 {
return nil, fmt.Errorf("username %s not found", username)
}
return res.Accounts[0], err
}

func deleteAccount(t *testing.T, id string) (*empty.Empty, error) {
cl := accountsProto.NewAccountsService("com.owncloud.api.accounts", service.Client())

Expand Down Expand Up @@ -1435,12 +1451,17 @@ func TestGetSingleUser(t *testing.T) {
t.Fatal(err)
}

a, err := findAccount(t, user.ID)
if err != nil {
t.Fatal(err)
}

formatpart := getFormatString(format)
res, err := sendRequest(
"GET",
fmt.Sprintf("/%v/cloud/user%v", ocsVersion, formatpart),
"",
&User{ID: user.ID},
&User{ID: a.Id},
[]string{ssvc.BundleUUIDRoleUser},
)

Expand Down

0 comments on commit a0eac80

Please sign in to comment.