From 90b3c902ec5e6cb7bace120aa7276cb41dc4e40f Mon Sep 17 00:00:00 2001 From: Robert Millard Date: Mon, 4 Nov 2024 12:07:42 +0100 Subject: [PATCH] fix updateuser endpoint --- client/user.go | 4 ++-- client/user_test.go | 2 +- metabase/resource_user.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/user.go b/client/user.go index 0ecda2c..9cff70a 100644 --- a/client/user.go +++ b/client/user.go @@ -71,8 +71,8 @@ func (c *Client) CreateUser(u User) (User, error) { return created, nil } -func (c *Client) UpdateUser(u User) (User, error) { - url := fmt.Sprintf("%s/api/user", c.BaseURL) +func (c *Client) UpdateUser(u User, id int) (User, error) { + url := fmt.Sprintf("%s/api/user/%d", c.BaseURL, id) b := new(bytes.Buffer) _ = json.NewEncoder(b).Encode(u) req, err := http.NewRequest(http.MethodPut, url, b) diff --git a/client/user_test.go b/client/user_test.go index 621a7d8..c8c73c8 100644 --- a/client/user_test.go +++ b/client/user_test.go @@ -106,7 +106,7 @@ func TestUser(t *testing.T) { HTTPClient: &http.Client{}, } - us, err := c.UpdateUser(userToBeUpdated) + us, err := c.UpdateUser(userToBeUpdated, 1) assert.Nil(t, err) assert.Equal(t, expected, us) diff --git a/metabase/resource_user.go b/metabase/resource_user.go index cac01e5..e31a041 100644 --- a/metabase/resource_user.go +++ b/metabase/resource_user.go @@ -61,7 +61,7 @@ func resourceUserUpdate(_ context.Context, d *schema.ResourceData, meta interfac } // Update the user - updated, err := c.UpdateUser(u) + updated, err := c.UpdateUser(u, userId) if err != nil { diags = append(diags, diag.Diagnostic{ Severity: diag.Error,