diff --git a/build/version_test.go b/build/version_test.go new file mode 100644 index 0000000..77bb2ee --- /dev/null +++ b/build/version_test.go @@ -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() + }) + } +} diff --git a/cmd/jobs_test.go b/cmd/jobs_test.go index 2f02163..af22473 100644 --- a/cmd/jobs_test.go +++ b/cmd/jobs_test.go @@ -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" diff --git a/config/config_test.go b/config/config_test.go index e30b962..f1fd3f7 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -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) }