2014-08-23 17:12:36 -04:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-02-17 05:35:23 -05:00
|
|
|
)
|
2014-08-23 17:12:36 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestCutUsageMessage(t *testing.T) {
|
2015-02-17 05:35:23 -05:00
|
|
|
tests := []struct{
|
|
|
|
message string
|
2014-08-23 17:12:36 -04:00
|
|
|
cutMessage string
|
|
|
|
}{
|
|
|
|
{"", ""},
|
2015-02-17 05:35:23 -05: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 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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|