From 50a38c92710d626d5a53255f460839edd2e4b929 Mon Sep 17 00:00:00 2001 From: alallema Date: Thu, 30 Jun 2022 14:21:14 +0200 Subject: [PATCH] Apply dumps changes --- .code-samples.meilisearch.yaml | 2 -- client.go | 7 +++--- client_test.go | 39 +++++----------------------------- 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index b35a4b3c..7d4c48da 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -591,8 +591,6 @@ faceted_search_walkthrough_filter_1: |- }) post_dump_1: |- resp, err := client.CreateDump() -get_dump_status_1: |- - resp, err := client.GetDumpStatus("dump-uid") phrase_search_1: |- resp, err := client.Index("movies").Search("\"african american\" horror", &meilisearch.SearchRequest{}) sorting_guide_update_sortable_attributes_1: |- diff --git a/client.go b/client.go index 02cd4442..561d07b7 100644 --- a/client.go +++ b/client.go @@ -45,8 +45,7 @@ type ClientInterface interface { UpdateKey(identifier string, request *Key) (resp *Key, err error) DeleteKey(identifier string) (resp bool, err error) GetAllStats() (resp *Stats, err error) - CreateDump() (resp *Dump, err error) - GetDumpStatus(dumpUID string) (resp *Dump, err error) + CreateDump() (resp *Task, err error) Version() (*Version, error) GetVersion() (resp *Version, err error) Health() (*Health, error) @@ -224,8 +223,8 @@ func (c *Client) IsHealthy() bool { return true } -func (c *Client) CreateDump() (resp *Dump, err error) { - resp = &Dump{} +func (c *Client) CreateDump() (resp *Task, err error) { + resp = &Task{} req := internalRequest{ endpoint: "/dumps", method: http.MethodPost, diff --git a/client_test.go b/client_test.go index 92feb0bc..7a1d7788 100644 --- a/client_test.go +++ b/client_test.go @@ -532,13 +532,13 @@ func TestClient_CreateDump(t *testing.T) { tests := []struct { name string client *Client - wantResp *Dump + wantResp *Task }{ { name: "TestCreateDump", client: defaultClient, - wantResp: &Dump{ - Status: "in_progress", + wantResp: &Task{ + Status: "enqueued", }, }, } @@ -554,8 +554,8 @@ func TestClient_CreateDump(t *testing.T) { // Waiting for CreateDump() to finished for { - gotResp, _ := c.GetDumpStatus(gotResp.UID) - if gotResp.Status == "done" { + gotResp, _ := c.GetTask(gotResp.TaskUID) + if gotResp.Status == "succeeded" { break } } @@ -563,35 +563,6 @@ func TestClient_CreateDump(t *testing.T) { } } -func TestClient_GetDumpStatus(t *testing.T) { - tests := []struct { - name string - client *Client - wantResp []DumpStatus - wantErr bool - }{ - { - name: "TestGetDumpStatus", - client: defaultClient, - wantResp: []DumpStatus{DumpStatusInProgress, DumpStatusFailed, DumpStatusDone}, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - c := tt.client - - dump, err := c.CreateDump() - require.NoError(t, err, "CreateDump() in TestGetDumpStatus error should be nil") - - gotResp, err := c.GetDumpStatus(dump.UID) - require.NoError(t, err) - require.Contains(t, tt.wantResp, gotResp.Status, "GetDumpStatus() got response status %v", gotResp.Status) - require.NotEqual(t, "failed", gotResp.Status, "GetDumpStatus() response status should not be failed") - }) - } -} - func TestClient_GetTask(t *testing.T) { type args struct { UID string