forgejo/modules/activitypub/user_settings_test.go
forgejo-backport-action abab629d90 [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/10662

- create the modules/testimport/import.go to centralize blank import needed for tests (in order to run the init() function)  to simplify maintenance
- remove the imports that are not needed

Co-authored-by: limiting-factor <limiting-factor@posteo.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10672
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2026-01-05 12:14:11 +01:00

29 lines
844 B
Go

// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package activitypub_test
import (
"testing"
"forgejo.org/models/db"
"forgejo.org/models/unittest"
user_model "forgejo.org/models/user"
"forgejo.org/modules/activitypub"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestUserSettings(t *testing.T) {
require.NoError(t, unittest.PrepareTestDatabase())
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
pub, priv, err := activitypub.GetKeyPair(db.DefaultContext, user1)
require.NoError(t, err)
pub1, err := activitypub.GetPublicKey(db.DefaultContext, user1)
require.NoError(t, err)
assert.Equal(t, pub, pub1)
priv1, err := activitypub.GetPrivateKey(db.DefaultContext, user1)
require.NoError(t, err)
assert.Equal(t, priv, priv1)
}