From bc2efb78241d6b031604cbc59d183195fc84c598 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 16 Nov 2015 10:00:06 -0800 Subject: [PATCH] jobspec: add test for types of nested configs --- jobspec/parse_test.go | 37 ++++++++++++++++++++ jobspec/test-fixtures/task-nested-config.hcl | 10 ++++++ 2 files changed, 47 insertions(+) create mode 100644 jobspec/test-fixtures/task-nested-config.hcl diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index 0814aa0f6..125127de5 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -225,6 +225,43 @@ func TestParse(t *testing.T) { }, false, }, + + { + "task-nested-config.hcl", + &structs.Job{ + Region: "global", + ID: "foo", + Name: "foo", + Type: "service", + Priority: 50, + + TaskGroups: []*structs.TaskGroup{ + &structs.TaskGroup{ + Name: "bar", + Count: 1, + RestartPolicy: &structs.RestartPolicy{ + Attempts: 2, + Interval: 1 * time.Minute, + Delay: 15 * time.Second, + }, + Tasks: []*structs.Task{ + &structs.Task{ + Name: "bar", + Driver: "docker", + Config: map[string]interface{}{ + "port_map": []map[string]interface{}{ + map[string]interface{}{ + "db": 1234, + }, + }, + }, + }, + }, + }, + }, + }, + false, + }, } for _, tc := range cases { diff --git a/jobspec/test-fixtures/task-nested-config.hcl b/jobspec/test-fixtures/task-nested-config.hcl new file mode 100644 index 000000000..428c90e2b --- /dev/null +++ b/jobspec/test-fixtures/task-nested-config.hcl @@ -0,0 +1,10 @@ +job "foo" { + task "bar" { + driver = "docker" + config { + port_map { + db = 1234 + } + } + } +}