Skip to content

Commit

Permalink
TG-237 Revert DocumentMeta changes (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwierzbo authored Mar 23, 2022
1 parent b8ee277 commit 94e4ee7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package driver

// DocumentMeta contains all meta data used to identifier a document.
type DocumentMeta struct {
Name string `json:"name,omitempty"`
Key string `json:"_key,omitempty"`
ID DocumentID `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Expand Down
9 changes: 7 additions & 2 deletions test/document_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,24 @@ func TestReadDocumentWithIfMatch(t *testing.T) {
ctx := context.Background()
ctx = driver.WithRevision(ctx, meta.Rev)

meta2, err := col.ReadDocument(ctx, meta.Key, &doc)
docResult := UserDoc{}
meta2, err := col.ReadDocument(ctx, meta.Key, &docResult)
if err != nil {
t.Fatalf("Failed to read document: %s", describe(err))
}
if meta2.Key != meta.Key || meta2.Rev != meta.Rev || meta2.ID != meta.ID {
t.Error("Read wrong meta data.")
}
if doc.Name != docResult.Name || doc.Age != docResult.Age {
t.Error("Read wrong UserDoc data.")
}

var resp driver.Response
ctx2 := context.Background()
ctx2 = driver.WithRevision(ctx2, "nonsense")
ctx2 = driver.WithResponse(ctx2, &resp)
_, err = col.ReadDocument(ctx2, meta.Key, &doc)

_, err = col.ReadDocument(ctx2, meta.Key, &docResult)
if err == nil {
t.Error("Reading with wrong revision did not fail")
}
Expand Down

0 comments on commit 94e4ee7

Please sign in to comment.