mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-25 00:21:43 +00:00
test: stop Test_CmdKeys from leaking re-initialized settings
Running the keys command in-process re-initializes settings, and since cli v3.10 a usage error also prints help (which re-initializes them too). That repointed the global RepoRootPath to a default under the data dir, tripping the SyncDirs guard in every later integration test. Set HideHelp so a usage error no longer prints help during the test. Assisted-by: Claude:Opus-4.8
This commit is contained in:
@@ -38,7 +38,8 @@ func Test_CmdKeys(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// FIXME: this test is not quite right. Each "command run" always re-initializes settings
|
||||
keysCmd := cmd.NewKeysCommand()
|
||||
keysCmd.Before = nil // don't re-initialize logger during the test
|
||||
keysCmd.Before = nil // don't re-initialize logger during the test
|
||||
keysCmd.HideHelp = true // skip help on usage error, which would re-initialize settings (cli v3.10)
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
app := &cli.Command{
|
||||
|
||||
Reference in New Issue
Block a user