forked from lunny/changelog
70c955ae17
Resolves #60 Extracts the previous trim into a new func as well to keep any title munging consistent. Reviewed-on: https://gitea.com/gitea/changelog/pulls/76 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io> Co-authored-by: jolheiser <john.olheiser@gmail.com> Co-committed-by: jolheiser <john.olheiser@gmail.com>
39 lines
794 B
Go
39 lines
794 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package service
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func TestCleanTitle(t *testing.T) {
|
|
tt := []struct {
|
|
Title string
|
|
Expected string
|
|
}{
|
|
{Title: "foo", Expected: "Foo"},
|
|
{Title: " foo", Expected: "Foo"},
|
|
{Title: "foo bar", Expected: "Foo bar"},
|
|
{Title: "Foo bar", Expected: "Foo bar"},
|
|
{Title: " Foo bar ", Expected: "Foo bar"},
|
|
{Title: "1234", Expected: "1234"},
|
|
}
|
|
|
|
for _, tc := range tt {
|
|
t.Run(tc.Title, func(t *testing.T) {
|
|
s := CleanTitle(tc.Title)
|
|
if s != tc.Expected {
|
|
t.Logf("got %q | expected %q", s, tc.Expected)
|
|
t.Fail()
|
|
}
|
|
})
|
|
}
|
|
}
|