-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add better error handling for config loading process
- Loading branch information
Showing
3 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestParseValidYaml(t *testing.T) { | ||
|
||
validYamlData := ` | ||
--- | ||
watch: | ||
- dir: /tmp/watch1 | ||
- dir: /tmp/watch2 | ||
profile: magento2 | ||
` | ||
c, err := Parse([]byte(validYamlData)) | ||
|
||
assert.NoError(t, err, "Config is valid and should not throw an error") | ||
assert.IsType(t, Config{}, c) | ||
} | ||
|
||
func TestParseInvalidYaml(t *testing.T) { | ||
invalidYamlData := ` | ||
--- | ||
watch | ||
` | ||
_, err := Parse([]byte(invalidYamlData)) | ||
|
||
assert.Error(t, err, "Config is invalid and should throw an error") | ||
} |