-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics_test.go
56 lines (41 loc) · 1.1 KB
/
metrics_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package wredis
import (
"context"
"time"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/suite"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/sdk/metric"
"testing"
)
type TestMetricsClientSuite struct {
suite.Suite
ctx context.Context
meter *Meter
basic UniversalClient
client *MetricsClient
}
func TestMetricsClient(t *testing.T) {
suite.Run(t, new(TestMetricsClientSuite))
}
type coll struct {
}
func (t *TestMetricsClientSuite) SetupTest() {
t.ctx = context.Background()
res, err := resource.New(t.ctx, resource.WithSchemaURL("http://localhost:9090"))
t.NoError(err)
meter := metric.NewMeterProvider(metric.WithResource(res))
t.basic, err = NewFactory(NewBuildConfig()).Build(t.ctx, Options{
Addr: "localhost:6379",
})
t.NoError(err)
t.client = NewMetricsClient("text-chache-module", t.basic, meter)
}
func (t *TestMetricsClientSuite) TestGet() {
err := t.client.Get(t.ctx, "test").Err()
t.ErrorIs(err, redis.Nil)
err = t.client.Set(t.ctx, "test", "test", time.Minute).Err()
t.NoError(err)
err = t.client.Get(t.ctx, "test").Err()
t.NoError(err)
}