mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-02 19:07:46 +00:00
fix stringPatternMatch() and create test
This commit is contained in:
@@ -36,6 +36,24 @@ func Test_AppNames(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func Test_stringPatternMatch(t *testing.T) {
|
||||
goodJsons := []map[string]interface{}{
|
||||
{"pattern":"*","name": "tom", "result": true},
|
||||
{"pattern":"aa","name": "tom", "result": false},
|
||||
{"pattern":"","name":"aa","result": false},
|
||||
{"pattern":"test*","name":"123testabc", "result": false},
|
||||
{"pattern":"test*","name":"testabc", "result": true},
|
||||
{"pattern":"*test*","name":"test1", "result": true},
|
||||
{"pattern":"*test","name":"123testabc", "result": false},
|
||||
{"pattern":"*test","name":"123test", "result": true},
|
||||
}
|
||||
for _, value := range goodJsons {
|
||||
if stringPatternMatch(value["pattern"].(string), value["name"].(string)) != value["result"].(bool) {
|
||||
t.Fatalf("Failed in %s match %s\n", value["pattern"].(string), value["name"].(string))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_getJSONPost(t *testing.T) {
|
||||
goodJsons := []string{
|
||||
`{"login":"abc","name": "tom", "pass": "mylittlepony", "admin": true}`,
|
||||
|
||||
Reference in New Issue
Block a user