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

Function TestGet

ch08/hexarch/core/core_test.go:57–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestGet(t *testing.T) {
58 store := NewKeyValueStore()
59
60 const key = "read-key"
61 const value = "read-value"
62
63 var val interface{}
64 var err error
65
66 defer delete(store.m, key)
67
68 // Read a non-thing
69 val, err = store.Get(key)
70 if err == nil {
71 t.Error("expected an error")
72 }
73 if !errors.Is(err, ErrorNoSuchKey) {
74 t.Error("unexpected error:", err)
75 }
76
77 store.m[key] = value
78
79 val, err = store.Get(key)
80 if err != nil {
81 t.Error("unexpected error:", err)
82 }
83
84 if val != value {
85 t.Error("val/value mismatch")
86 }
87}
88
89func TestDelete(t *testing.T) {
90 store := NewKeyValueStore()

Callers

nothing calls this directly

Calls 2

GetMethod · 0.95
NewKeyValueStoreFunction · 0.85

Tested by

no test coverage detected