-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
template rendering, single values & tests
- Loading branch information
Showing
4 changed files
with
90 additions
and
15 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,40 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestFuncMapDefault(t *testing.T) { | ||
|
||
// parameters & return | ||
tSet := map[string][][]interface{}{ | ||
"default": { | ||
{nil, 1, 1}, | ||
{5, 1, 5}, | ||
{"", "1", "1"}, | ||
{nil, nil, fmt.Errorf("")}, | ||
}, | ||
"contains": { | ||
{"aa.", ".", true}, | ||
{"ss", ".", false}, | ||
}} | ||
|
||
for name, set := range tSet { | ||
fn := funcMap[name].(func(interface{}, interface{}) (interface{}, error)) | ||
|
||
for _, p := range set { | ||
exp := p[len(p)-1] | ||
var expe error | ||
switch v := exp.(type) { | ||
case error: | ||
expe = v | ||
exp = nil | ||
} | ||
res, err := fn(p[0], p[1]) | ||
if res != exp || (err != nil && expe == nil) { | ||
t.Errorf("%v expected %v got %v error %v err: %v", p, exp, res, expe, err) | ||
} | ||
} | ||
} | ||
} |
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