MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / Test_EntryMostFunctions

Function Test_EntryMostFunctions

internal/core/entry_test.go:59–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func Test_EntryMostFunctions(t *testing.T) {
60 r := require.New(t)
61 k := []byte("key")
62 v := []byte("value")
63 ttl := 12
64 txId := 121212
65 bucketId := uint64(9)
66 entry := core.NewEntry().
67 WithKey(k).
68 WithValue(v).
69 WithMeta(
70 core.NewMetaData().
71 WithTTL(uint32(ttl)).
72 WithTxID(uint64(txId)).
73 WithDs(core.DataStructureBTree).
74 WithBucketId(bucketId).
75 WithKeySize(3).
76 WithValueSize(5).
77 WithFlag(core.DataBTreeBucketDeleteFlag),
78 )
79
80 r.Equal(entry.Key, k)
81 data := entry.Encode()
82 // test encode
83 checkFuncs := []func(buf []byte) []byte{
84 func(buf []byte) []byte {
85 // crc32 check
86 t.Log("crc32 check")
87 length := 4
88 crc := binary.LittleEndian.Uint32(buf[0:length])
89 r.Equal(crc, crc32.ChecksumIEEE(buf[length:]))
90 return buf[length:]
91 },
92 func(buf []byte) []byte {
93 // timestamp check
94 t.Log("timestamp check")
95 ts, length := binary.Uvarint(buf[0:])
96 r.Equal(entry.Meta.Timestamp, ts)
97 return buf[length:]
98 },
99 func(buf []byte) []byte {
100 // key size check
101 t.Log("keySize check")
102 ks, length := binary.Uvarint(buf[0:])
103 r.Equal(uint64(entry.Meta.KeySize), ks)
104 return buf[length:]
105 },
106 func(buf []byte) []byte {
107 t.Log("valueSize check")
108 vs, length := binary.Uvarint(buf[0:])
109 r.Equal(uint64(entry.Meta.ValueSize), vs)
110 return buf[length:]
111 },
112 func(buf []byte) []byte {
113 t.Log("Flag check")
114 flag, length := binary.Uvarint(buf[0:])
115 r.Equal(uint64(entry.Meta.Flag), flag)
116 return buf[length:]

Callers

nothing calls this directly

Calls 15

NewEntryFunction · 0.92
NewMetaDataFunction · 0.92
WithMetaMethod · 0.80
WithFlagMethod · 0.80
WithKeySizeMethod · 0.80
WithBucketIdMethod · 0.80
WithDsMethod · 0.80
GetRawKeyMethod · 0.80
IsBelongsToBTreeMethod · 0.80
IsFilterMethod · 0.80
WithValueMethod · 0.45
WithKeyMethod · 0.45

Tested by

no test coverage detected