-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathplugin_test.go
50 lines (44 loc) · 968 Bytes
/
plugin_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
package dotweb
import (
"fmt"
"github.com/devfeel/dotweb/test"
"testing"
"time"
)
type testPlugin struct {
}
func (p *testPlugin) Name() string {
return "test"
}
func (p *testPlugin) Run() error {
fmt.Println(p.Name(), "runing")
//panic("error test run")
return nil
}
func (p *testPlugin) IsValidate() bool {
return true
}
func TestNotifyPlugin_Name(t *testing.T) {
app := newConfigDotWeb()
//fmt.Println(app.Config.ConfigFilePath)
p := NewDefaultNotifyPlugin(app)
needShow := "NotifyPlugin"
test.Equal(t, needShow, p.Name())
}
func TestNotifyPlugin_IsValidate(t *testing.T) {
app := newConfigDotWeb()
p := NewDefaultNotifyPlugin(app)
needShow := true
test.Equal(t, needShow, p.IsValidate())
}
func TestNotifyPlugin_Run(t *testing.T) {
app := newConfigDotWeb()
p := NewDefaultNotifyPlugin(app)
go func() {
for {
fmt.Println(p.ModTimes[app.Config.ConfigFilePath])
time.Sleep(time.Duration(600 * time.Millisecond))
}
}()
p.Run()
}