File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import (
1919var 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 ,
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments