-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor testing to use light config definitions
- Loading branch information
Victor Castell
committed
Aug 24, 2018
1 parent
e5cb765
commit ab311af
Showing
10 changed files
with
168 additions
and
254 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,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/victorcoder/dkron/dkron" | ||
) | ||
|
||
func TestReadConfigTags(t *testing.T) { | ||
viper.Reset() | ||
viper.SetConfigType("yaml") | ||
var jsonConfig = []byte(` | ||
tags: | ||
- foo: bar | ||
`) | ||
viper.ReadConfig(bytes.NewBuffer(jsonConfig)) | ||
config := &dkron.Config{} | ||
viper.Unmarshal(config) | ||
t.Log(config.Tags) | ||
assert.Equal(t, "bar", config.Tags["foo"]) | ||
|
||
viper.Set("tag", []string{"monthy=python"}) | ||
viper.Unmarshal(config) | ||
assert.NotContains(t, config.Tags, "foo") | ||
assert.Contains(t, config.Tags, "monthy") | ||
assert.Equal(t, "python", config.Tags["monthy"]) | ||
|
||
config = &dkron.Config{Tags: map[string]string{"t1": "v1", "t2": "v2"}} | ||
assert.Equal(t, "v1", config.Tags["t1"]) | ||
assert.Equal(t, "v2", config.Tags["t2"]) | ||
} |
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
Oops, something went wrong.