Skip to content

Commit 300256c

Browse files
committed
Fix tests in order to use the UpdateParams struct insted of the hardcoded payload
1 parent 54ec802 commit 300256c

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

opensearchapi/api_update_test.go

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func TestUpdate(t *testing.T) {
4848
resp, err := client.Update(
4949
nil,
5050
opensearchapi.UpdateReq{
51+
Params: opensearchapi.UpdateParams{Source: true}
5152
Index: testIndex,
5253
DocumentID: "1",
5354
Body: strings.NewReader(`{"script":{"source":"ctx._source.counter += params.count","lang":"painless","params":{"count":4}}}`),
@@ -68,39 +69,3 @@ func TestUpdate(t *testing.T) {
6869
osapitest.VerifyInspect(t, res.Inspect())
6970
})
7071
}
71-
72-
func TestUpdateResp_WithSource(t *testing.T) {
73-
data := `{
74-
"_index": "test",
75-
"_id": "1",
76-
"_version": 1,
77-
"result": "noop",
78-
"_shards": {"total":1,"successful":1,"failed":0},
79-
"_seq_no": 1,
80-
"_primary_term": 1,
81-
"get": {
82-
"_index": "test",
83-
"_id": "1",
84-
"_version": 1,
85-
"_seq_no": 1,
86-
"_primary_term": 1,
87-
"found": true,
88-
"_source": {"foo":"bar"}
89-
}
90-
}`
91-
92-
var resp opensearchapi.UpdateResp
93-
err := json.Unmarshal([]byte(data), &resp)
94-
if err != nil {
95-
t.Fatalf("unexpected error: %v", err)
96-
}
97-
98-
if resp.Get == nil || !resp.Get.Found {
99-
t.Fatalf("expected get field to be present and found=true")
100-
}
101-
102-
expected := `{"foo":"bar"}`
103-
if string(resp.Get.Source) != expected {
104-
t.Errorf("expected %s, got %s", expected, string(resp.Get.Source))
105-
}
106-
}

0 commit comments

Comments
 (0)