Skip to content

Commit

Permalink
Merge pull request #7 from kolesa-team/default-values-fix
Browse files Browse the repository at this point in the history
Some fixes for Default Values Filter
  • Loading branch information
antonsergeyev authored Jun 2, 2022
2 parents c17b03c + 3000e46 commit f29d04e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion http-api-mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var ErrNotFoundDefaultPath = errors.New("We can't determinate the current path")
var ErrNotFoundAnyMock = errors.New("No valid mock definition found")

func banner() {
fmt.Println("HTTP API Mock v 1.1.5")
fmt.Println("HTTP API Mock v 1.2.1")
fmt.Println("")

fmt.Print(
Expand Down
2 changes: 1 addition & 1 deletion vars/default_values_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type DefaultValuesFilter struct {
}

func (dvf DefaultValuesFilter) Fill(_ *definition.Mock, input string, _ bool) string {
r := regexp.MustCompile(`\{\{\s*default\.([^{]+?)\s*}}`)
r := regexp.MustCompile(`\{\{\s*default\.[A-Za-z]+\(.*\,*\)\s*}}`)
if r.MatchString(input) {
input = dvf.Process(r, input)
}
Expand Down
3 changes: 1 addition & 2 deletions vars/vars_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ func (fp VarsProcessor) Eval(req *definition.Request, m *definition.Mock) {

// handle possible dynamic values and use it in storage again
fp.walkAndFill(dynamicVarsFiller, m, true)
fp.walkAndFill(defaultValuesVarsFiller, m, true)
fp.walkAndFill(storageFiller, m, true)

entityActions.ApplyActions(m)

fp.walkAndFill(defaultValuesVarsFiller, m, true)
fp.walkAndFill(persistFiller, m, false)

}

func (fp VarsProcessor) walkAndFill(f Filler, m *definition.Mock, fillPersisted bool) {
Expand Down

0 comments on commit f29d04e

Please sign in to comment.