forked from CiscoCloud/marathon-consul
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_test.go
More file actions
73 lines (66 loc) · 1.81 KB
/
app_test.go
File metadata and controls
73 lines (66 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"encoding/json"
"github.com/stretchr/testify/assert"
"testing"
)
var testApp = App{
Args: []string{"arg"},
BackoffFactor: 0.5,
BackoffSeconds: 1,
Cmd: "command",
Constraints: [][]string{[]string{"HOSTNAME", "unique"}},
Container: &Container{
Type: "DOCKER",
Volumes: []Volume{Volume{ContainerPath: "/tmp", HostPath: "/tmp/container", Mode: "rw"}},
Docker: &Docker{
Image: "alpine",
Parameters: []Parameter{Parameter{"hostname", "container.example.com"}},
Privileged: true,
PortMappings: []PortMapping{PortMapping{8080, 8080, 0, "tcp"}},
Network: "BRIDGED",
ForcePullImage: true,
},
},
CPUs: 0.1,
Dependencies: []string{"/otherApp"},
Disk: 128,
Env: map[string]string{"HOME": "/tmp"},
Executor: "executor",
Labels: map[string]string{"BALANCE": "yes"},
HealthChecks: []HealthCheck{HealthCheck{
Path: "/",
PortIndex: 0,
Protocol: "http",
GracePeriodSeconds: 30,
IntervalSeconds: 15,
TimeoutSeconds: 30,
MaxConsecutiveFailures: 5,
}},
ID: "/test",
Instances: 2,
Mem: 256,
Ports: []int{10001},
RequirePorts: true,
StoreUrls: []string{"http://example.com/resource/"},
UpgradeStrategy: UpgradeStrategy{
MinimumHealthCapacity: 1.0,
MaximumOverCapacity: 1.0,
},
Uris: []string{"http://example.com/"},
User: "user",
Version: "2015-01-01T00:00:00Z",
}
func TestAppKey(t *testing.T) {
t.Parallel()
app := &App{ID: "a/b/c"}
assert.Equal(t, app.Key(), "a-b-c")
}
func TestAppKV(t *testing.T) {
t.Parallel()
jsonified, err := json.Marshal(testApp)
assert.Nil(t, err)
kv := testApp.KV()
assert.Equal(t, kv.Key, testApp.Key())
assert.Equal(t, kv.Value, jsonified)
}