@@ -11,7 +11,7 @@ import (
11
11
var noopPresets = make (map [string ]string )
12
12
13
13
func parseAndCompare (t * testing.T , rawEnvLine string , expectedKey string , expectedValue string ) {
14
- key , value , _ := parseLine (rawEnvLine )
14
+ key , value , _ := parseLine (rawEnvLine , noopPresets )
15
15
if key != expectedKey || value != expectedValue {
16
16
t .Errorf ("Expected '%v' to parse as '%v' => '%v', got '%v' => '%v' instead" , rawEnvLine , expectedKey , expectedValue , key , value )
17
17
}
@@ -193,6 +193,19 @@ func TestLoadQuotedEnv(t *testing.T) {
193
193
loadEnvAndCompareValues (t , Load , envFileName , expectedValues , noopPresets )
194
194
}
195
195
196
+ func TestSubstituitions (t * testing.T ) {
197
+ envFileName := "fixtures/substitutions.env"
198
+ expectedValues := map [string ]string {
199
+ "OPTION_A" : "1" ,
200
+ "OPTION_B" : "1" ,
201
+ "OPTION_C" : "1" ,
202
+ "OPTION_D" : "11" ,
203
+ "OPTION_E" : "" ,
204
+ }
205
+
206
+ loadEnvAndCompareValues (t , Load , envFileName , expectedValues , noopPresets )
207
+ }
208
+
196
209
func TestActualEnvVarsAreLeftAlone (t * testing.T ) {
197
210
os .Clearenv ()
198
211
os .Setenv ("OPTION_A" , "actualenv" )
@@ -280,7 +293,7 @@ func TestParsing(t *testing.T) {
280
293
// it 'throws an error if line format is incorrect' do
281
294
// expect{env('lol$wut')}.to raise_error(Dotenv::FormatError)
282
295
badlyFormattedLine := "lol$wut"
283
- _ , _ , err := parseLine (badlyFormattedLine )
296
+ _ , _ , err := parseLine (badlyFormattedLine , noopPresets )
284
297
if err == nil {
285
298
t .Errorf ("Expected \" %v\" to return error, but it didn't" , badlyFormattedLine )
286
299
}
@@ -348,7 +361,7 @@ func TestWrite(t *testing.T) {
348
361
//but single quotes are left alone
349
362
writeAndCompare (`key=va'lu'e` , `key="va'lu'e"` )
350
363
// newlines, backslashes, and some other special chars are escaped
351
- writeAndCompare (`foo="$ba \n\r\\r!"` , `foo="\$ba \n\r\\r\!"` )
364
+ writeAndCompare (`foo="\n\r\\r!"` , `foo="\n\r\\r\!"` )
352
365
// lines should be sorted
353
366
writeAndCompare ("foo=bar\n baz=buzz" , "baz=\" buzz\" \n foo=\" bar\" " )
354
367
0 commit comments