1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-26 18:20:57 +00:00
forgejo/models/quota/used_test.go
forgejo-backport-action ed87ecd17f [v11.0/forgejo] fix: ignore expired artifacts for quota calculation (#7985)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/7976

- Expired artifacts are kept in the database but the artifact has been deleted from the storage. Ignore them for the quota calculation.
- Added unit test.

Co-authored-by: Gusted <postmaster@gusted.xyz>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7985
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>
2025-05-28 19:00:00 +02:00

23 lines
551 B
Go

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package quota
import (
"testing"
"forgejo.org/models/unittest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetUsedForUser(t *testing.T) {
defer unittest.OverrideFixtures("models/fixtures/TestGetUsedForUser/")()
require.NoError(t, unittest.PrepareTestDatabase())
used, err := GetUsedForUser(t.Context(), 5)
require.NoError(t, err)
assert.EqualValues(t, 4096, used.Size.Assets.Artifacts)
}