Skip to content

Commit

Permalink
documenting tests around null characters in job id, task group name, …
Browse files Browse the repository at this point in the history
…and task name
  • Loading branch information
cgbaker committed Oct 5, 2020
1 parent fc10e8f commit d4ef12e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@ func TestJob_ValidateScaling(t *testing.T) {
require.Contains(mErr.Errors[0].Error(), "task group count must not be less than minimum count in scaling policy")
}

func TestJob_ValidateNullChar(t *testing.T) {
assert := assert.New(t)

// job id should not allow null characters
job := testJob()
job.ID = "id_with\000null_character"
assert.Error(job.Validate(), "null character in job ID should not validate")

// task group name should not allow null characters
job.ID = "happy_little_job_id"
job.TaskGroups[0].Name = "oh_no_another_\000_char"
assert.Error(job.Validate(), "null character in task group name should not validate")

// task name should not allow null characters
job.TaskGroups[0].Name = "so_much_better"
job.TaskGroups[0].Tasks[0].Name = "what_is_with_these_\000_chars"
assert.Error(job.Validate(), "null character in task name should not validate")
}

func TestJob_Warnings(t *testing.T) {
cases := []struct {
Name string
Expand Down

0 comments on commit d4ef12e

Please sign in to comment.