Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions opensearchapi/api_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type UpdateResp struct {
SeqNo int `json:"_seq_no"`
PrimaryTerm int `json:"_primary_term"`
Type string `json:"_type"` // Deprecated field
Get *DocumentGetResp `json:"get,omitempty"`
response *opensearch.Response
}

Expand Down
36 changes: 36 additions & 0 deletions opensearchapi/api_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,39 @@
osapitest.VerifyInspect(t, res.Inspect())
})
}

func TestUpdateResp_WithSource(t *testing.T) {
data := `{
"_index": "test",
"_id": "1",
"_version": 1,
"result": "noop",
"_shards": {"total":1,"successful":1,"failed":0},
"_seq_no": 1,
"_primary_term": 1,
"get": {
"_index": "test",
"_id": "1",
"_version": 1,
"_seq_no": 1,
"_primary_term": 1,
"found": true,
"_source": {"foo":"bar"}
}
}`

var resp UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.3.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.0.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.1.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.2.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.13.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.10.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.3.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.0.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.18.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.2.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.1.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.4.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 1.3.18)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.8.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.9.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.10.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.4.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 1.3.18)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.12.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.8.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.7.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.18.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.5.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.11.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.15.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.19.2)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.9.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.6.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.17.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.5.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / Tests

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.6.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.14.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.7.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.14.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.16.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 3.0.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.16.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.13.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.12.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.17.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.11.1)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 3.0.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / Tests against secure cluster

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.15.0)

undefined: UpdateResp

Check failure on line 91 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.19.2)

undefined: UpdateResp
err := json.Unmarshal([]byte(data), &resp)

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.3.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.0.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.1.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.2.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.13.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.10.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.3.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.0.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.18.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.2.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.1.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.4.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 1.3.18)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.8.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.9.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.10.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.4.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 1.3.18)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.12.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.8.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.7.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.18.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.5.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.11.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.15.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.19.2)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.9.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.6.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.17.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.5.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / Tests

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.6.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.14.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.7.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.14.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.16.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 3.0.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.16.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.13.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.12.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.17.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.11.1)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 3.0.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / Tests against secure cluster

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (false, 2.15.0)

undefined: json

Check failure on line 92 in opensearchapi/api_update_test.go

View workflow job for this annotation

GitHub Actions / integ-test-compat (true, 2.19.2)

undefined: json
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

if resp.Get == nil || !resp.Get.Found {
t.Fatalf("expected get field to be present and found=true")
}

expected := `{"foo":"bar"}`
if string(resp.Get.Source) != expected {
t.Errorf("expected %s, got %s", expected, string(resp.Get.Source))
}
}
Loading