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

Function TestTable_AddField

internal/utils/kvstore/table_field_test.go:50–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestTable_AddField(t *testing.T) {
51 var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
52
53 defer func() {
54 _ = testingStore.Close()
55 }()
56
57 err := table.AddFields("expiresAt")
58 if err != nil {
59 t.Fatal(err)
60 }
61
62 var before = time.Now()
63 for _, item := range []*testCachedItem{
64 {
65 Hash: "a1",
66 URL: "https://example.com/a1",
67 ExpiresAt: 1710832067,
68 },
69 {
70 Hash: "a5",
71 URL: "https://example.com/a5",
72 ExpiresAt: time.Now().Unix() + 7200,
73 },
74 {
75 Hash: "a4",
76 URL: "https://example.com/a4",
77 ExpiresAt: time.Now().Unix() + 86400,
78 },
79 {
80 Hash: "a3",
81 URL: "https://example.com/a3",
82 ExpiresAt: time.Now().Unix() + 1800,
83 },
84 {
85 Hash: "a2",
86 URL: "https://example.com/a2",
87 ExpiresAt: time.Now().Unix() + 365*86400,
88 },
89 } {
90 err = table.Set(item.Hash, item)
91 if err != nil {
92 t.Fatal(err)
93 }
94 }
95
96 t.Log("set cost:", time.Since(before).Seconds()*1000, "ms")
97
98 testInspectDB(t)
99}
100
101func TestTable_AddField_Many(t *testing.T) {
102 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 6

testInspectDBFunction · 0.85
AddFieldsMethod · 0.80
UnixMethod · 0.80
LogMethod · 0.80
CloseMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected