Skip to content

Commit

Permalink
Test parsing of body field in jobspec2
Browse files Browse the repository at this point in the history
  • Loading branch information
nick96 committed Mar 25, 2021
1 parent 0ed91b1 commit 2a92901
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions jobspec2/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,3 +844,52 @@ func TestParse_Meta_Alternatives(t *testing.T) {
require.Equal(t, map[string]string{"source": "task"}, asBlock.TaskGroups[0].Tasks[0].Meta)

}

func TestParseServiceCheck(t *testing.T) {
hcl := ` job "group_service_check_script" {
group "group" {
service {
name = "foo-service"
port = "http"
check {
name = "check-name"
type = "http"
method = "POST"
body = "{\"check\":\"mem\"}"
}
}
}
}
`
parsedJob, err := ParseWithConfig(&ParseConfig{
Path: "input.hcl",
Body: []byte(hcl),
})
require.NoError(t, err)

expectedJob := &api.Job{
ID: stringToPtr("group_service_check_script"),
Name: stringToPtr("group_service_check_script"),
TaskGroups: []*api.TaskGroup{
{
Name: stringToPtr("group"),
Services: []*api.Service{
{
Name: "foo-service",
PortLabel: "http",
Checks: []api.ServiceCheck{
{
Name: "check-name",
Type: "http",
Method: "POST",
Body: "{\"check\":\"mem\"}",
},
},
},
},
},
},
}

require.Equal(t, expectedJob, parsedJob)
}

0 comments on commit 2a92901

Please sign in to comment.