Skip to content

Commit c5b6d34

Browse files
committed
update readme, add parse config error test
1 parent 73d8d44 commit c5b6d34

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
os: [ubuntu-latest, macos-latest, windows-latest]
14+
os: [ubuntu-latest, macos-latest]
1515
go-version: ["1.17"]
1616
steps:
1717
- uses: actions/checkout@v2

Readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,16 @@ type Config struct {
147147

148148
If object is a map, the keys are the environment variables and the values are the values.
149149

150+
### Note
151+
152+
- Not tested with Windows.
153+
150154
### Todo or not todo
151155

152156
- Add a `-force` flag to `sicher init` to overwrite the encrypted file if it already exists
153157
- Enable support for nested yaml env files
154158
- Add support for other types of encryption
159+
- Test on windows
155160

156161
### License
157162

helpers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@ func generateKey() string {
7878
// parseConfig parses the environment variables into a map
7979
func parseConfig(config []byte, store map[string]string, envType EnvStyle) (err error) {
8080

81-
if envType != DOTENV && envType != YAML && envType != YML {
81+
delim, ok := envStyleDelim[envType]
82+
if !ok {
8283
return errors.New("invalid environment type")
8384
}
8485

85-
delim := envStyleDelim[envType]
86-
8786
var b bytes.Buffer
8887
b.Write(config)
8988
sc := bufio.NewScanner(&b)

helpers_test.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,29 +161,16 @@ func TestParseConfig(t *testing.T) {
161161

162162
}
163163

164-
func TestYamlParseConfig(t *testing.T) {
164+
func TestYamlParseConfigError(t *testing.T) {
165165
enMap := make(map[string]string)
166166
cfg := []byte(`
167167
PORT:8080
168168
URI:localhost
169169
#OLD_PORT:5000
170170
`)
171-
err := parseConfig(cfg, enMap, "yaml")
172-
if err != nil {
173-
t.Errorf("Unable to parse config; %v", err)
174-
}
175-
176-
port, ok := enMap["PORT"]
177-
if !ok {
178-
t.Errorf("Expected config to have been marshalled into map")
179-
}
180-
181-
if port != "8080" {
182-
t.Errorf("Expected value to be %s, got %s", "8080", port)
183-
}
184-
185-
if enMap["OLD_PORT"] != "" {
186-
t.Errorf("Expected ignored value to not be parsed")
171+
err := parseConfig(cfg, enMap, "wrong")
172+
if err == nil {
173+
t.Errorf("Expected error to be thrown when parsing wrong envType")
187174
}
188175
}
189176

0 commit comments

Comments
 (0)