mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-02-19 01:27:55 -05:00
Update the Forgejo driver for gof3 with modifications for non-backward compatible changes. The changes are isolated behind the f3.Enable flag and not yet functional. The purpose of this upgrade is to not drift from the gof3 implementation while the work continues.
The `fix: include remote users when counting users` commit is a functional change to Forgejo itself but does not change the behavior because the remote users are only created in fixtures or by F3.
59c721d26b/models/user/user.go (L65-L66)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10673
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: limiting-factor <limiting-factor@posteo.com>
Co-committed-by: limiting-factor <limiting-factor@posteo.com>
74 lines
1.4 KiB
Go
74 lines
1.4 KiB
Go
// Copyright 2024 The Forgejo Authors.
|
|
// SPDX-License-Identifier: GPLv3-or-later
|
|
|
|
package setting
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"forgejo.org/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSettingF3(t *testing.T) {
|
|
restoreF3 := test.MockProtect(&F3)
|
|
restoreAppDataPath := test.MockProtect(&AppDataPath)
|
|
restore := func() {
|
|
restoreF3()
|
|
restoreAppDataPath()
|
|
}
|
|
defer restore()
|
|
|
|
t.Run("enabled", func(t *testing.T) {
|
|
restore()
|
|
cfg, err := NewConfigProviderFromData(`
|
|
[f3]
|
|
ENABLED = true
|
|
`)
|
|
require.NoError(t, err)
|
|
loadF3From(cfg)
|
|
assert.True(t, F3.Enabled)
|
|
assert.DirExists(t, F3.Path)
|
|
})
|
|
|
|
t.Run("disabled by default", func(t *testing.T) {
|
|
restore()
|
|
cfg, err := NewConfigProviderFromData(`
|
|
[f3]
|
|
`)
|
|
require.NoError(t, err)
|
|
loadF3From(cfg)
|
|
assert.False(t, F3.Enabled)
|
|
})
|
|
|
|
t.Run("default f3 path", func(t *testing.T) {
|
|
restore()
|
|
cfg, err := NewConfigProviderFromData(`
|
|
[f3]
|
|
ENABLED = true
|
|
`)
|
|
require.NoError(t, err)
|
|
AppDataPath = t.TempDir()
|
|
loadF3From(cfg)
|
|
assert.Equal(t, AppDataPath+"/f3", F3.Path)
|
|
assert.DirExists(t, F3.Path)
|
|
})
|
|
|
|
t.Run("absolute f3 path", func(t *testing.T) {
|
|
restore()
|
|
other := t.TempDir()
|
|
cfg, err := NewConfigProviderFromData(fmt.Sprintf(`
|
|
[f3]
|
|
ENABLED = true
|
|
PATH = %[1]s
|
|
`, other))
|
|
require.NoError(t, err)
|
|
AppDataPath = t.TempDir()
|
|
loadF3From(cfg)
|
|
assert.Equal(t, other, F3.Path)
|
|
assert.DirExists(t, F3.Path)
|
|
})
|
|
}
|