From fbbb09a3cbe049ae2749c224afd721fefced6470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=91=D0=BE=D1=80=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Thu, 12 Feb 2026 17:16:28 +0200 Subject: [PATCH] working commit --- pkg/client/account.go | 34 ++++++++++++++++++++++++++++++++-- pkg/client/account_test.go | 32 +++++++++----------------------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/pkg/client/account.go b/pkg/client/account.go index ec099c5..84371b5 100644 --- a/pkg/client/account.go +++ b/pkg/client/account.go @@ -151,7 +151,38 @@ func (cli *Client) UpdateAccount(ctx context.Context, hosturi, id, username, new return err } -func (cli *Client) DeleteAccount(ctx context.Context, hosturi, id, username string) error { +func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username string) error { + var err error + + apipath, err := setApiPath(hosturi, "/v3/api/account/delete") + if err != nil { + return err + } + operParams := operator.DeleteAccountParams{ + Username: username, + } + paramsJson, err := json.Marshal(operParams) + if err != nil { + return err + } + respBytes, err := doHTTPCall(ctx, apipath, paramsJson) + if err != nil { + return err + } + + operRes := handler.NewResponse[operator.DeleteAccountResult]() + err = json.Unmarshal(respBytes, operRes) + if err != nil { + return err + } + if operRes.Error { + err = fmt.Errorf("%s", operRes.Message) + return err + } + return err +} + +func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi, id string) error { var err error apipath, err := setApiPath(hosturi, "/v3/api/account/delete") @@ -159,7 +190,6 @@ func (cli *Client) DeleteAccount(ctx context.Context, hosturi, id, username stri return err } operParams := operator.DeleteAccountParams{ - Username: username, AccountID: id, } paramsJson, err := json.Marshal(operParams) diff --git a/pkg/client/account_test.go b/pkg/client/account_test.go index 0313ea6..5927ec8 100644 --- a/pkg/client/account_test.go +++ b/pkg/client/account_test.go @@ -115,30 +115,16 @@ func TestAccountLife(t *testing.T) { fmt.Printf("accounts:\n%s\n", string(accountsYAML)) } - /* - { - // DeleteAccount - fmt.Printf("=== DeleteAccount ===\n") - cli := NewClient() - ctx := context.Background() - ctx, _ = context.WithTimeout(ctx, 1*time.Second) + { + // DeleteAccount + fmt.Printf("=== DeleteAccount ===\n") + cli := NewClient() + ctx := context.Background() + ctx, _ = context.WithTimeout(ctx, 1*time.Second) - err = cli.DeleteAccount(ctx, srvaddr+"/foo.bin") - require.NoError(t, err) - } + err = cli.DeleteAccountByID(ctx, srvaddr, accountID) + require.NoError(t, err) + } - { - // !AccountExists - fmt.Printf("=== AccountExists ===\n") - cli := NewClient() - ctx := context.Background() - ctx, _ = context.WithTimeout(ctx, 1*time.Second) - - exists, _, err := cli.AccountInfo(ctx, srvaddr+"/foo.bin") - require.NoError(t, err) - require.False(t, exists) - - } - */ }