This commit is contained in:
Alex Dadgar 2015-12-18 12:17:50 -08:00
parent ea119b7297
commit 55cc8c61b3
5 changed files with 18 additions and 6 deletions

View File

@ -80,6 +80,9 @@ func (c *RunCommand) Run(args []string) int {
return 1
}
// Initialize any fields that need to be.
job.InitFields()
// Check that the job is valid
if err := job.Validate(); err != nil {
c.Ui.Error(fmt.Sprintf("Error validating job: %s", err))

View File

@ -77,6 +77,7 @@ func TestRunCommand_Fails(t *testing.T) {
defer os.Remove(fh3.Name())
_, err = fh3.WriteString(`
job "job1" {
type = "service"
datacenters = [ "dc1" ]
group "group1" {
count = 1

View File

@ -48,6 +48,9 @@ func (c *ValidateCommand) Run(args []string) int {
return 1
}
// Initialize any fields that need to be.
job.InitFields()
// Check that the job is valid
if err := job.Validate(); err != nil {
c.Ui.Error(fmt.Sprintf("Error validating job: %s", err))

View File

@ -24,6 +24,7 @@ func TestValidateCommand(t *testing.T) {
defer os.Remove(fh.Name())
_, err = fh.WriteString(`
job "job1" {
type = "service"
datacenters = [ "dc1" ]
group "group1" {
count = 1

View File

@ -115,9 +115,11 @@ func TestJob_IsPeriodic(t *testing.T) {
func TestTaskGroup_Validate(t *testing.T) {
tg := &TaskGroup{
RestartPolicy: &RestartPolicy{
Interval: 5 * time.Minute,
Delay: 10 * time.Second,
Attempts: 10,
Interval: 5 * time.Minute,
Delay: 10 * time.Second,
Attempts: 10,
RestartOnSuccess: true,
Mode: RestartPolicyModeDelay,
},
}
err := tg.Validate()
@ -141,9 +143,11 @@ func TestTaskGroup_Validate(t *testing.T) {
&Task{},
},
RestartPolicy: &RestartPolicy{
Interval: 5 * time.Minute,
Delay: 10 * time.Second,
Attempts: 10,
Interval: 5 * time.Minute,
Delay: 10 * time.Second,
Attempts: 10,
RestartOnSuccess: true,
Mode: RestartPolicyModeDelay,
},
}
err = tg.Validate()