@@ -81,6 +81,11 @@ func TestAcceptFileValidate(t *testing.T) {
81
81
valid : true ,
82
82
envVars : map [string ]string {"API" : "value" , "OTHER" : "othervalue" },
83
83
},
84
+ {
85
+ content : `{"vars": ["${API:foo.api.com}"], "private": []}` ,
86
+ valid : true ,
87
+ envVars : map [string ]string {},
88
+ },
84
89
}
85
90
86
91
for _ , file := range files {
@@ -119,9 +124,10 @@ func TestAcceptFileValidate(t *testing.T) {
119
124
func TestRenderEnvVars (t * testing.T ) {
120
125
121
126
vars := map [string ]string {
122
- "API" : "value" ,
123
- "OTHER" : "othervalue" ,
124
- "plugin" : "nope" ,
127
+ "API" : "value" ,
128
+ "OTHER" : "othervalue" ,
129
+ "plugin" : "nope" ,
130
+ "NOT_MISSING" : "set_value" ,
125
131
}
126
132
127
133
for k , v := range vars {
@@ -136,13 +142,13 @@ func TestRenderEnvVars(t *testing.T) {
136
142
cfg := axonConfig .NewAgentEnvConfig ()
137
143
138
144
content := `{
139
- "$vars":["${env:API}", "${OTHER}", "${plugin:foo}", "${OTHER}"], "private": []}`
145
+ "$vars":["${env:API}", "${OTHER}", "${plugin:foo}", "${OTHER}","${MISSING:default_value}","${NOT_MISSING:default_value}" ], "private": []}`
140
146
141
147
af , err := NewAcceptFile ([]byte (content ), cfg , nil )
142
148
require .NoError (t , err )
143
149
rendered , err := af .Render (zap .NewNop ())
144
150
require .NoError (t , err )
145
- expected := `{"$vars":["${API}","${OTHER}","{{plugin:foo}}","${OTHER}"],"private":[{"method":"any","origin":"http://localhost:80","path":"/__axon/*"}],"public":[]}`
151
+ expected := `{"$vars":["${API}","${OTHER}","{{plugin:foo}}","${OTHER}","default_value","${NOT_MISSING}" ],"private":[{"method":"any","origin":"http://localhost:80","path":"/__axon/*"}],"public":[]}`
146
152
require .Equal (t , expected , string (rendered ), "Rendered accept file does not match expected output" )
147
153
}
148
154
0 commit comments