forked from mcuadros/ofelia
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon_test.go
63 lines (46 loc) · 1.2 KB
/
common_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
package middlewares
import (
"testing"
"github.com/mcuadros/ofelia/core"
. "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
type SuiteCommon struct {
BaseSuite
}
var _ = Suite(&SuiteCommon{})
func (s *SuiteCommon) TestIsEmpty(c *C) {
config := &TestConfig{}
c.Assert(IsEmpty(config), Equals, true)
config = &TestConfig{Foo: "foo"}
c.Assert(IsEmpty(config), Equals, false)
config = &TestConfig{Qux: 42}
c.Assert(IsEmpty(config), Equals, false)
}
type BaseSuite struct {
ctx *core.Context
job *TestJob
}
func (s *BaseSuite) SetUpTest(c *C) {
s.job = &TestJob{}
sh := core.NewScheduler(&TestLogger{})
e := core.NewExecution()
s.ctx = core.NewContext(sh, s.job, e)
}
type TestConfig struct {
Foo string
Qux int
Bar bool
}
type TestJob struct {
core.BareJob
}
func (j *TestJob) Run(ctx *core.Context) error {
return nil
}
type TestLogger struct{}
func (*TestLogger) Criticalf(format string, args ...interface{}) {}
func (*TestLogger) Debugf(format string, args ...interface{}) {}
func (*TestLogger) Errorf(format string, args ...interface{}) {}
func (*TestLogger) Noticef(format string, args ...interface{}) {}
func (*TestLogger) Warningf(format string, args ...interface{}) {}