MCPcopy
hub / github.com/hashicorp/go-memdb / TestTxn_InsertUpdate_First

Function TestTxn_InsertUpdate_First

txn_test.go:68–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestTxn_InsertUpdate_First(t *testing.T) {
69 db := testDB(t)
70 txn := db.Txn(true)
71
72 obj := &TestObject{
73 ID: "my-object",
74 Foo: "abc",
75 Qux: []string{"abc1", "abc2"},
76 }
77 err := txn.Insert("main", obj)
78 if err != nil {
79 t.Fatalf("err: %v", err)
80 }
81
82 raw, err := txn.First("main", "id", obj.ID)
83 if err != nil {
84 t.Fatalf("err: %v", err)
85 }
86
87 if raw != obj {
88 t.Fatalf("bad: %#v %#v", raw, obj)
89 }
90
91 // Update the object
92 obj2 := &TestObject{
93 ID: "my-object",
94 Foo: "xyz",
95 Qux: []string{"xyz1", "xyz2"},
96 }
97 err = txn.Insert("main", obj2)
98 if err != nil {
99 t.Fatalf("err: %v", err)
100 }
101
102 raw, err = txn.First("main", "id", obj.ID)
103 if err != nil {
104 t.Fatalf("err: %v", err)
105 }
106
107 if raw != obj2 {
108 t.Fatalf("bad: %#v %#v", raw, obj)
109 }
110}
111
112func TestTxn_InsertUpdate_First_NonUnique(t *testing.T) {
113 db := testDB(t)

Callers

nothing calls this directly

Calls 4

testDBFunction · 0.85
TxnMethod · 0.80
InsertMethod · 0.80
FirstMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…