-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathengine_test.go
64 lines (52 loc) · 1.37 KB
/
engine_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
57
58
59
60
61
62
63
64
// Copyright 2022 YBCZ, Inc. All rights reserved.
//
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file in the root of the source
// tree.
package mqms
import (
"encoding/json"
"github.com/google/uuid"
"log"
"testing"
"time"
)
type testHandler struct {
}
func (t testHandler) Pub(evtRaw json.RawMessage, duration time.Duration) (err error) {
log.Println(string(evtRaw), duration)
return
}
func (t testHandler) Save(evtID uuid.UUID, evtRaw json.RawMessage, duration time.Duration) (err error) {
log.Println(evtID, string(evtRaw), duration)
return
}
func (t testHandler) Trace(trace Trace) {
raw, _ := json.Marshal(trace)
log.Println(string(raw))
}
func (t testHandler) Log(l string) {
log.Println(l)
}
func (t testHandler) Fail(evtID uuid.UUID, evtRaw json.RawMessage, err error, stack []string) {
log.Println(evtID, string(evtRaw), err, stack)
}
func (t testHandler) DoRead() (list []Row, err error) {
return
}
func (t testHandler) HttpTrace(ht HttpTrace) {
raw, _ := json.Marshal(ht)
log.Println(string(raw))
}
var _ IEngineHandler = &testHandler{}
func TestMqmsTrace(t *testing.T) {
log.SetFlags(log.Ltime | log.Lshortfile)
var h = new(testHandler)
engine := New(h)
engine.Item("test", func(c *Context) (err error) {
//err = c.Error(errors.New("test error"))
return
})
engine.Emit("test", "F")
time.Sleep(time.Hour)
}