-
Notifications
You must be signed in to change notification settings - Fork 36
/
json.feature
103 lines (91 loc) · 4.05 KB
/
json.feature
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Feature: JSON environment data source
Scenario: Load fixture
Given I use a fixture named "json"
Then a file named "environments/array.yaml" should exist
Scenario: Set environment variable
Given I set the environment variables exactly to:
| variable | value |
| tiller_json | '{ "key" : "value" }' |
When I run `env`
Then the output should contain "tiller_json"
Scenario: Simple data from environment
Given I use a fixture named "json"
Given I set the environment variables exactly to:
| variable | value |
| tiller_json | { "default_value" : "from JSON!" , "key1" : "value1" , "key2" : "value2" } |
When I successfully run `tiller -b . -v -n -e simple_keys`
Then a file named "simple_keys.txt" should exist
And the file "simple_keys.txt" should contain:
"""
Default value : from JSON!
* Key 1 is : value1
* Key 2 is : value2
"""
And the output should contain "default_value => 'from defaults' being replaced by : 'From the file datasource' from FileDataSource"
And the output should contain "default_value => 'From the file datasource' being replaced by : 'from JSON!' from EnvironmentJsonDataSource"
Scenario: Simple data from environment v2 format
Given I use a fixture named "json"
Given I set the environment variables exactly to:
| variable | value |
| tiller_json | { "_version" : 2 , "global" : { "default_value" : "from JSON!" , "key1" : "value1" , "key2" : "value2" } } |
When I successfully run `tiller -b . -v -n -e simple_keys`
Then a file named "simple_keys.txt" should exist
And the file "simple_keys.txt" should contain:
"""
Default value : from JSON!
* Key 1 is : value1
* Key 2 is : value2
"""
Scenario: Simple template data from environment v2 format
Given I use a fixture named "json"
Given I set the environment variables exactly to:
| variable | value |
| tiller_json | { "_version" : 2 , "simple_keys.erb" : { "default_value" : "from JSON!" , "key1" : "value1" , "key2" : "value2" } } |
When I successfully run `tiller -b . -v -n -e simple_keys`
Then a file named "simple_keys.txt" should exist
And the file "simple_keys.txt" should contain:
"""
Default value : from JSON!
* Key 1 is : value1
* Key 2 is : value2
"""
Scenario: Array data from environment
Given I use a fixture named "json"
Given I set the environment variables exactly to:
| variable | value |
| tiller_json | { "servers" : [ "server1" , "server2" , "server3" ] } |
When I successfully run `tiller -b . -v -n -e array`
Then a file named "array.txt" should exist
And the file "array.txt" should contain:
"""
This is a list of all servers:
Server : server1
Server : server2
Server : server3
"""
Scenario: Override defaults from environment
Given I use a fixture named "json"
Given I set the environment variables exactly to:
| variable | value |
| tiller_json | { "default_value" : "from JSON!" , "key1" : "value1" , "key2" : "value2" } |
When I successfully run `tiller -b . -v -n -e override`
Then a file named "simple_keys.txt" should exist
And the file "simple_keys.txt" should contain "from JSON!"
Scenario: Don't die if missing tiller_json environment variable
Given a file named "common.yaml" with:
"""
---
data_sources: [ "file" , "environment_json" ]
template_sources: [ "file" ]
exec: [ "true" ]
environments:
development:
test.erb:
target: test.txt
"""
And a file named "templates/test.erb" with:
"""
Test value : <%= test_value %>
"""
When I successfully run `tiller -b . -v -n `
Then a file named "test.txt" should exist