Skip to content

Commit d633217

Browse files
committed
fix test
1 parent 7bceb6c commit d633217

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cmd/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
var CmdKeys = &cli.Command{
2020
Name: "keys",
2121
Usage: "(internal) Should only be called by SSH server",
22-
Hidden: true, // internal commands shouldn't not be visible
22+
Hidden: true, // internal commands shouldn't be visible
2323
Description: "Queries the Gitea database to get the authorized command for a given ssh key fingerprint",
2424
Before: PrepareConsoleLoggerLevel(log.FATAL),
2525
Action: runKeys,

tests/integration/cmd_keys_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"code.gitea.io/gitea/cmd"
1212
"code.gitea.io/gitea/modules/setting"
13+
"code.gitea.io/gitea/modules/test"
1314
"code.gitea.io/gitea/modules/util"
1415

1516
"github.com/stretchr/testify/assert"
@@ -36,13 +37,15 @@ func Test_CmdKeys(t *testing.T) {
3637
}
3738
for _, tt := range tests {
3839
t.Run(tt.name, func(t *testing.T) {
40+
// FIXME: this test is not quite right. Each "command run" always re-initializes settings
41+
defer test.MockVariableValue(&cmd.CmdKeys.Before, nil)() // don't re-initialize logger during the test
42+
3943
var stdout, stderr bytes.Buffer
4044
app := &cli.Command{
4145
Writer: &stdout,
4246
ErrWriter: &stderr,
4347
Commands: []*cli.Command{cmd.CmdKeys},
4448
}
45-
cmd.CmdKeys.HideHelp = true
4649
err := app.Run(t.Context(), append([]string{"prog"}, tt.args...))
4750
if tt.wantErr {
4851
assert.Error(t, err)

0 commit comments

Comments
 (0)