mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
8c1a4da804
Read HISTORY.md https://github.com/kataras/iris/blob/master/HISTORY.md#sa-19-august-2017--v831 Former-commit-id: 23f7c1c0dc3bc64f27db591a9b22cd5934337891
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)
|
|
}
|
|
}
|
|
}
|
|
}
|