MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestTable_ComposeFieldKey

Function TestTable_ComposeFieldKey

internal/utils/kvstore/table_test.go:290–308  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

288}
289
290func TestTable_ComposeFieldKey(t *testing.T) {
291 var a = assert.NewAssertion(t)
292
293 var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
294
295 defer func() {
296 _ = testingStore.Close()
297 }()
298
299 var fieldKeyBytes = table.ComposeFieldKey([]byte("Lily"), "username", []byte("lucy"))
300 t.Log(string(fieldKeyBytes))
301 fieldValueBytes, keyValueBytes, err := table.DecodeFieldKey("username", fieldKeyBytes)
302 if err != nil {
303 t.Fatal(err)
304 }
305 t.Log("field:", string(fieldValueBytes), "key:", string(keyValueBytes))
306 a.IsTrue(string(fieldValueBytes) == "lucy")
307 a.IsTrue(string(keyValueBytes) == "Lily")
308}
309
310func BenchmarkTable_Set(b *testing.B) {
311 runtime.GOMAXPROCS(4)

Callers

nothing calls this directly

Calls 4

ComposeFieldKeyMethod · 0.80
LogMethod · 0.80
DecodeFieldKeyMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected