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

Function TestKVTask_Add

internal/metrics/task_kv_test.go:60–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestKVTask_Add(t *testing.T) {
61 var task = metrics.NewKVTask(&serverconfigs.MetricItemConfig{
62 Id: 1,
63 IsOn: false,
64 Category: "",
65 Period: 1,
66 PeriodUnit: serverconfigs.MetricItemPeriodUnitDay,
67 Keys: []string{"${remoteAddr}"},
68 Value: "${countRequest}",
69 })
70 err := task.Init()
71 if err != nil {
72 t.Fatal(err)
73 }
74 err = task.Start()
75 if err != nil {
76 t.Fatal(err)
77 }
78 defer func() {
79 _ = task.Stop()
80 }()
81
82 task.Add(&testObj{ip: "127.0.0.2"})
83
84 if testutils.IsSingleTesting() {
85 time.Sleep(1 * time.Second) // waiting for inserting
86 }
87}
88
89func TestKVTask_Add_Many(t *testing.T) {
90 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 6

NewKVTaskFunction · 0.92
IsSingleTestingFunction · 0.92
InitMethod · 0.65
StartMethod · 0.65
StopMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected