mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package templates
|
|
|
|
import (
|
|
"context"
|
|
"html/template"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRenderCommitBody(t *testing.T) {
|
|
type args struct {
|
|
ctx context.Context
|
|
msg string
|
|
urlPrefix string
|
|
metas map[string]string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want template.HTML
|
|
}{
|
|
{
|
|
name: "multiple lines",
|
|
args: args{
|
|
ctx: context.Background(),
|
|
msg: "first line\nsecond line",
|
|
},
|
|
want: "second line",
|
|
},
|
|
{
|
|
name: "multiple lines with leading newlines",
|
|
args: args{
|
|
ctx: context.Background(),
|
|
msg: "\n\n\n\nfirst line\nsecond line",
|
|
},
|
|
want: "second line",
|
|
},
|
|
{
|
|
name: "multiple lines with trailing newlines",
|
|
args: args{
|
|
ctx: context.Background(),
|
|
msg: "first line\nsecond line\n\n\n",
|
|
},
|
|
want: "second line",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert.Equalf(t, tt.want, RenderCommitBody(tt.args.ctx, tt.args.msg, tt.args.urlPrefix, tt.args.metas), "RenderCommitBody(%v, %v, %v, %v)", tt.args.ctx, tt.args.msg, tt.args.urlPrefix, tt.args.metas)
|
|
})
|
|
}
|
|
}
|
|
|