mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
32 lines
916 B
Go
32 lines
916 B
Go
|
package mvc
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestFindCtrlWords(t *testing.T) {
|
||
|
var tests = map[string][]string{
|
||
|
"UserController": {"user"},
|
||
|
"UserPostController": {"user", "post"},
|
||
|
"ProfileController": {"profile"},
|
||
|
"UserProfileController": {"user", "profile"},
|
||
|
"UserProfilePostController": {"user", "profile", "post"},
|
||
|
"UserProfile": {"user", "profile"},
|
||
|
"Profile": {"profile"},
|
||
|
"User": {"user"},
|
||
|
}
|
||
|
|
||
|
for ctrlName, expected := range tests {
|
||
|
words := findCtrlWords(ctrlName)
|
||
|
if len(expected) != len(words) {
|
||
|
t.Fatalf("expected words and return don't have the same length: [%d] != [%d] | '%s' != '%s'",
|
||
|
len(expected), len(words), expected, words)
|
||
|
}
|
||
|
for i, w := range words {
|
||
|
if expected[i] != w {
|
||
|
t.Fatalf("expected word is not equal with the return one: '%s' != '%s'", expected[i], w)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|