Added tests for service block parsing
This commit is contained in:
parent
ead6e09a79
commit
36520a90b3
|
@ -436,7 +436,7 @@ func parseTasks(result *[]*structs.Task, list *ast.ObjectList) error {
|
|||
service.Checks = make([]structs.ServiceCheck, len(co.Items))
|
||||
for idx, co := range co.Items {
|
||||
var check structs.ServiceCheck
|
||||
label := o.Keys[0].Token.Value().(string)
|
||||
label := co.Keys[0].Token.Value().(string)
|
||||
var cm map[string]interface{}
|
||||
if err := hcl.DecodeObject(&cm, co.Val); err != nil {
|
||||
return err
|
||||
|
|
|
@ -94,6 +94,23 @@ func TestParse(t *testing.T) {
|
|||
Config: map[string]interface{}{
|
||||
"image": "hashicorp/binstore",
|
||||
},
|
||||
Services: []structs.Service{
|
||||
{
|
||||
Id: "service-id",
|
||||
Name: "service-name",
|
||||
Tags: []string{"foo", "bar"},
|
||||
PortLabel: "http",
|
||||
Checks: []structs.ServiceCheck{
|
||||
{
|
||||
Id: "check-id",
|
||||
Name: "check-name",
|
||||
Type: "tcp",
|
||||
Interval: 10 * time.Second,
|
||||
Timeout: 2 * time.Second,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Env: map[string]string{
|
||||
"HELLO": "world",
|
||||
"LOREM": "ipsum",
|
||||
|
|
|
@ -45,6 +45,17 @@ job "binstore-storagelocker" {
|
|||
HELLO = "world"
|
||||
LOREM = "ipsum"
|
||||
}
|
||||
service "service-id" {
|
||||
name = "service-name"
|
||||
tags = ["foo", "bar"]
|
||||
port = "http"
|
||||
check "check-id" {
|
||||
name = "check-name"
|
||||
type = "tcp"
|
||||
interval = "10s"
|
||||
timeout = "2s"
|
||||
}
|
||||
}
|
||||
resources {
|
||||
cpu = 500
|
||||
memory = 128
|
||||
|
|
Loading…
Reference in a new issue