(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestParseEnvFile(t *testing.T) { |
| 12 | for i, tc := range []struct { |
| 13 | input string |
| 14 | expect map[string]string |
| 15 | shouldErr bool |
| 16 | }{ |
| 17 | { |
| 18 | input: `KEY=value`, |
| 19 | expect: map[string]string{ |
| 20 | "KEY": "value", |
| 21 | }, |
| 22 | }, |
| 23 | { |
| 24 | input: ` |
| 25 | KEY=value |
| 26 | OTHER_KEY=Some Value |
| 27 | `, |
| 28 | expect: map[string]string{ |
| 29 | "KEY": "value", |
| 30 | "OTHER_KEY": "Some Value", |
| 31 | }, |
| 32 | }, |
| 33 | { |
| 34 | input: ` |
| 35 | KEY=value |
| 36 | INVALID KEY=asdf |
| 37 | OTHER_KEY=Some Value |
| 38 | `, |
| 39 | shouldErr: true, |
| 40 | }, |
| 41 | { |
| 42 | input: ` |
| 43 | KEY=value |
| 44 | SIMPLE_QUOTED="quoted value" |
| 45 | OTHER_KEY=Some Value |
| 46 | `, |
| 47 | expect: map[string]string{ |
| 48 | "KEY": "value", |
| 49 | "SIMPLE_QUOTED": "quoted value", |
| 50 | "OTHER_KEY": "Some Value", |
| 51 | }, |
| 52 | }, |
| 53 | { |
| 54 | input: ` |
| 55 | KEY=value |
| 56 | NEWLINES="foo |
| 57 | bar" |
| 58 | OTHER_KEY=Some Value |
| 59 | `, |
| 60 | expect: map[string]string{ |
| 61 | "KEY": "value", |
| 62 | "NEWLINES": "foo\n\tbar", |
| 63 | "OTHER_KEY": "Some Value", |
| 64 | }, |
| 65 | }, |
| 66 | { |
| 67 | input: ` |
| 68 | KEY=value |
nothing calls this directly
no test coverage detected