2014-08-23 21:12:36 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-03-05 22:19:10 +00:00
|
|
|
)
|
2014-08-23 21:12:36 +00:00
|
|
|
|
|
|
|
func TestCutUsageMessage(t *testing.T) {
|
2015-03-05 22:19:10 +00:00
|
|
|
tests := []struct {
|
|
|
|
message string
|
2014-08-23 21:12:36 +00:00
|
|
|
cutMessage string
|
|
|
|
}{
|
|
|
|
{"", ""},
|
2015-03-05 22:19:10 +00:00
|
|
|
{" Usage of hugo: \n -b, --baseUrl=...", ""},
|
|
|
|
{"Some error Usage of hugo: \n", "Some error"},
|
|
|
|
{"Usage of hugo: \n -b --baseU", ""},
|
|
|
|
{"CRITICAL error for usage of hugo ", "CRITICAL error for usage of hugo"},
|
|
|
|
{"Invalid short flag a in -abcde", "Invalid short flag a in -abcde"},
|
2014-08-23 21:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
message := cutUsageMessage(test.message)
|
|
|
|
if message != test.cutMessage {
|
|
|
|
t.Errorf("Expected %#v, got %#v", test.cutMessage, message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|