MCPcopy Create free account
hub / github.com/cloud-native-go/examples / TestPut

Function TestPut

ch08/grpc/keyvalue_server/core_test.go:24–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestPut(t *testing.T) {
25 const key = "create-key"
26 const value = "create-value"
27
28 var val interface{}
29 var contains bool
30
31 defer delete(store.m, key)
32
33 // Sanity check
34 _, contains = store.m[key]
35 if contains {
36 t.Error("key/value already exists")
37 }
38
39 // err should be nil
40 err := Put(key, value)
41 if err != nil {
42 t.Error(err)
43 }
44
45 val, contains = store.m[key]
46 if !contains {
47 t.Error("create failed")
48 }
49
50 if val != value {
51 t.Error("val/value mismatch")
52 }
53}
54
55func TestGet(t *testing.T) {
56 const key = "read-key"

Callers

nothing calls this directly

Calls 1

PutFunction · 0.70

Tested by

no test coverage detected