Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liujianping committed May 20, 2019
1 parent b5b0b77 commit 26ea60d
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 12 deletions.
30 changes: 30 additions & 0 deletions build/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package build

import "testing"

func TestInfo(t *testing.T) {
type args struct {
v string
m string
d string
}
tests := []struct {
name string
args args
}{
{
"info",
args{
v: "v0.1.0",
m: "commit",
d: "20190520",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Info(tt.args.v, tt.args.m, tt.args.d)
Print()
})
}
}
1 change: 1 addition & 0 deletions cmd/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestJOBs(t *testing.T) {
job2.Name = "two"
job2.Command.Shell.Name = "echo"
job2.Order.Weight = 2
job2.Order.Precondition = []string{"one"}

job3 := config.CommandJD()
job3.Name = "three"
Expand Down
60 changes: 48 additions & 12 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,54 @@ func TestCommandJD(t *testing.T) {
assert.NotNil(t, jd2)

opts := []Option{}
opts = append(opts, Name("name"))
opts = append(opts, Metadata("key", "val"))
opts = append(opts, CommandName("echo"))
opts = append(opts, CommandArgs("aa", "bb", "cc"))
opts = append(opts, CommandEnv("key", "val"))
opts = append(opts, CommandRetry(3))
opts = append(opts, CommandStdoutDiscard(true))
opts = append(opts, CommandTimeout(time.Second))
opts = append(opts, RepeatTimes(10))
opts = append(opts, RepeatInterval(time.Second))
opts = append(opts, Concurrent(10))
opts = append(opts, Crontab("* * * * *"))
opt := Name("name")
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = Metadata("key", "val")
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = CommandName("echo")
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = CommandArgs("aa", "bb", "cc")
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = CommandEnv("key", "val")
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = CommandRetry(3)
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = CommandStdoutDiscard(true)
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = CommandTimeout(time.Second)
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = RepeatTimes(10)
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = RepeatInterval(time.Second)
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = Concurrent(10)
assert.NotNil(t, opt)
opts = append(opts, opt)

opt = Crontab("* * * * *")
assert.NotNil(t, opt)
opts = append(opts, opt)

for _, opt := range opts {
opt(jd1)
}
Expand Down

0 comments on commit 26ea60d

Please sign in to comment.