-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from ivanilves/with
refactor: add WithNameEx() func to wrap arbitrary regex rule
- Loading branch information
Showing
5 changed files
with
35 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ vendor/ | |
/cmd/travelgrunt/* | ||
!/cmd/travelgrunt/*.go | ||
/dist/* | ||
|
||
# Local Makefile | ||
local.mk |
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,12 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/ivanilves/travelgrunt/pkg/config/rule" | ||
) | ||
|
||
// WithNameEx returns a copy of config with regex-based rule added | ||
func (cfg Config) WithNameEx(nameEx string) Config { | ||
cfg.Rules = []rule.Rule{rule.Rule{NameEx: nameEx}} | ||
|
||
return cfg | ||
} |
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,17 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestWithNameEx(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
cfg := DefaultConfig() | ||
|
||
cfg = cfg.WithNameEx("*.tf") | ||
|
||
assert.Len(cfg.Rules, 1) | ||
} |