@@ -31,22 +31,37 @@ func TestReadAndExportEnv(t *testing.T) {
3131 tests := []struct {
3232 name string
3333 exportFunc ExportFunction
34+ ejsonFile string
3435 expectedOutput string
3536 }{
3637 {
3738 name : "ExportEnv" ,
3839 exportFunc : ExportEnv ,
40+ ejsonFile : "testdata/test-expected-usage.ejson" ,
3941 expectedOutput : "export test_key='test value'\n " ,
4042 },
4143 {
4244 name : "ExportQuiet" ,
4345 exportFunc : ExportQuiet ,
46+ ejsonFile : "testdata/test-expected-usage.ejson" ,
4447 expectedOutput : "test_key='test value'\n " ,
4548 },
49+ {
50+ name : "ExportEnvTrimUnderscore" ,
51+ exportFunc : TrimLeadingUnderscoreExportWrapper (ExportEnv ),
52+ ejsonFile : "testdata/test-leading-underscore-env-key.ejson" ,
53+ expectedOutput : "export test_key='test value'\n " ,
54+ },
55+ {
56+ name : "ExportEnvNoTrimUnderscore" ,
57+ exportFunc : ExportEnv ,
58+ ejsonFile : "testdata/test-leading-underscore-env-key.ejson" ,
59+ expectedOutput : "export _test_key='test value'\n " ,
60+ },
4661 }
4762
4863 for _ , test := range tests {
49- err := ReadAndExportEnv ("testdata/ test-expected-usage.ejson" , "./key" , TestKeyValue , test .exportFunc )
64+ err := ReadAndExportEnv (test . ejsonFile , "./key" , TestKeyValue , test .exportFunc )
5065 if nil != err {
5166 t .Errorf ("testing %s failed: %s" , test .name , err )
5267 continue
0 commit comments