-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathopencensus_test.go
52 lines (38 loc) · 939 Bytes
/
opencensus_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
/*
* Copyright (c) Fabio da Silva Ribeiro <[email protected]>
* SPDX-License-Identifier: MIT
*/
package middleware
import (
"testing"
"github.com/labstack/echo/v4"
"go.opencensus.io/stats/view"
)
func TestOpenCensus(t *testing.T) {
ec := reqCtx(t)
_ = OpenCensus()(testHandler)(ec)
}
func TestOpenCensusWithEmptyConfig(t *testing.T) {
ec := reqCtx(t)
_ = OpenCensusWithConfig(OpenCensusConfig{})(testHandler)(ec)
}
func TestOpenCensusWithSkipper(t *testing.T) {
ec := reqCtx(t)
config := DefaultOpenCensusConfig
config.Skipper = func(echo.Context) bool {
return true
}
_ = OpenCensusWithConfig(config)(testHandler)(ec)
}
func TestOpenCensusWithWrongView(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Error("expected a panic when register views")
}
}()
ec := reqCtx(t)
config := OpenCensusConfig{
Views: []*view.View{{}},
}
_ = OpenCensusWithConfig(config)(testHandler)(ec)
}