Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
42 lines
1 KiB
Go
42 lines
1 KiB
Go
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package repo
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"forgejo.org/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestReleaseListLoadAttributes(t *testing.T) {
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
releases := ReleaseList{&Release{
|
|
RepoID: 1,
|
|
PublisherID: 1,
|
|
}, &Release{
|
|
RepoID: 2,
|
|
PublisherID: 2,
|
|
}, &Release{
|
|
RepoID: 1,
|
|
PublisherID: 2,
|
|
}, &Release{
|
|
RepoID: 2,
|
|
PublisherID: 1,
|
|
}}
|
|
|
|
require.NoError(t, releases.LoadAttributes(t.Context()))
|
|
|
|
assert.EqualValues(t, 1, releases[0].Repo.ID)
|
|
assert.EqualValues(t, 1, releases[0].Publisher.ID)
|
|
assert.EqualValues(t, 2, releases[1].Repo.ID)
|
|
assert.EqualValues(t, 2, releases[1].Publisher.ID)
|
|
assert.EqualValues(t, 1, releases[2].Repo.ID)
|
|
assert.EqualValues(t, 2, releases[2].Publisher.ID)
|
|
assert.EqualValues(t, 2, releases[3].Repo.ID)
|
|
assert.EqualValues(t, 1, releases[3].Publisher.ID)
|
|
}
|