Esempio n. 1
0
// cronをconfigから生成するテスト
func TestNewCron(t *testing.T) {
	conf := createTestConfig()
	child := createTestConfig()

	conf.Jobs = []*config.Job{
		&config.Job{
			Schedule: "0 * * * * ?",
			User:     "******",
			Command:  "echo newcron1",
		},
	}

	child.Jobs = []*config.Job{
		&config.Job{
			Schedule: "0 * * * * ?",
			User:     "******",
			Command:  "echo newcron2",
		},
	}

	conf.Childs = []*config.Config{child}

	cron, err := newCron(conf)
	if err != nil {
		t.Error(err)
	} else if cron == nil {
		t.Error("cron create failed")
	} else if 0 == len(cron.Entries()) {
		t.Error("cron register job failed.")
	}
}
Esempio n. 2
0
// ジョブ登録テスト
func TestRegisterJob(t *testing.T) {
	cron := &cron.Cron{}
	conf := createTestConfig()

	job := &config.Job{
		Schedule: "0 * * * * ?",
		User:     "******",
		Command:  "echo registerjob",
	}

	err := registerJob(cron, conf, job)
	if err != nil {
		t.Error(err)
	} else if 0 == len(cron.Entries()) {
		t.Errorf("job entries: %d", len(cron.Entries()))
	}
}
Esempio n. 3
0
// ジョブ登録失敗テスト
func TestRegisterJobFail(t *testing.T) {
	cron := &cron.Cron{}
	conf := createTestConfig()

	job := &config.Job{
		Schedule: "0 aaa * * * ?",
		User:     "******",
		Command:  "echo registerjob failed",
	}

	err := registerJob(cron, conf, job)

	if err == nil {
		t.Error("register job successful.")
	} else if 0 < len(cron.Entries()) {
		t.Errorf("register job successful: %d", len(cron.Entries()))
	}
}