2014-08-23 17:12:36 -04:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-03-05 17:19:10 -05:00
|
|
|
)
|
2014-08-23 17:12:36 -04:00
|
|
|
|
|
|
|
func TestCutUsageMessage(t *testing.T) {
|
2015-03-05 17:19:10 -05:00
|
|
|
tests := []struct {
|
|
|
|
message string
|
2014-08-23 17:12:36 -04:00
|
|
|
cutMessage string
|
|
|
|
}{
|
|
|
|
{"", ""},
|
2015-09-09 01:27:55 -04:00
|
|
|
{" Usage of hugo: \n -b, --baseURL=...", ""},
|
2015-03-05 17:19:10 -05:00
|
|
|
{"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 17:12:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
message := cutUsageMessage(test.message)
|
|
|
|
if message != test.cutMessage {
|
|
|
|
t.Errorf("Expected %#v, got %#v", test.cutMessage, message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|