mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-01 04:54:09 +00:00
4de909747b
go-require lint is ignored for now Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4535 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
36 lines
932 B
Go
36 lines
932 B
Go
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_22 //nolint
|
|
|
|
import (
|
|
"testing"
|
|
|
|
migration_tests "code.gitea.io/gitea/models/migrations/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_RemoveSSHSignaturesFromReleaseNotes(t *testing.T) {
|
|
// A reduced mock of the `repo_model.Release` struct.
|
|
type Release struct {
|
|
ID int64 `xorm:"pk autoincr"`
|
|
Note string `xorm:"TEXT"`
|
|
}
|
|
|
|
x, deferable := migration_tests.PrepareTestEnv(t, 0, new(Release))
|
|
defer deferable()
|
|
|
|
require.NoError(t, RemoveSSHSignaturesFromReleaseNotes(x))
|
|
|
|
var releases []Release
|
|
err := x.Table("release").OrderBy("id ASC").Find(&releases)
|
|
require.NoError(t, err)
|
|
assert.Len(t, releases, 3)
|
|
|
|
assert.Equal(t, "", releases[0].Note)
|
|
assert.Equal(t, "A message.\n", releases[1].Note)
|
|
assert.Equal(t, "no signature present here", releases[2].Note)
|
|
}
|