Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-shell
Commits
f6bf0514
Commit
f6bf0514
authored
5 years ago
by
Igor
Committed by
Nick Thomas
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return Fallback cmd if feature is enabled, but unimplemented
parent
4342831a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
go/internal/command/command.go
go/internal/command/command.go
+3
-1
go/internal/command/command_test.go
go/internal/command/command_test.go
+17
-10
No files found.
go/internal/command/command.go
View file @
f6bf0514
...
...
@@ -22,7 +22,9 @@ func New(arguments []string, config *config.Config, readWriter *readwriter.ReadW
}
if
config
.
FeatureEnabled
(
string
(
args
.
CommandType
))
{
return
buildCommand
(
args
,
config
,
readWriter
),
nil
if
cmd
:=
buildCommand
(
args
,
config
,
readWriter
);
cmd
!=
nil
{
return
cmd
,
nil
}
}
return
&
fallback
.
Command
{
RootDir
:
config
.
RootDir
,
Args
:
arguments
},
nil
...
...
This diff is collapsed.
Click to expand it.
go/internal/command/command_test.go
View file @
f6bf0514
...
...
@@ -16,14 +16,12 @@ import (
func
TestNew
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
desc
string
arguments
[]
string
config
*
config
.
Config
environment
map
[
string
]
string
expectedType
interface
{}
}{
{
desc
:
"it returns a Discover command if the feature is enabled"
,
arguments
:
[]
string
{},
desc
:
"it returns a Discover command if the feature is enabled"
,
config
:
&
config
.
Config
{
GitlabUrl
:
"http+unix://gitlab.socket"
,
Migration
:
config
.
MigrationConfig
{
Enabled
:
true
,
Features
:
[]
string
{
"discover"
}},
...
...
@@ -35,8 +33,7 @@ func TestNew(t *testing.T) {
expectedType
:
&
discover
.
Command
{},
},
{
desc
:
"it returns a Fallback command no feature is enabled"
,
arguments
:
[]
string
{},
desc
:
"it returns a Fallback command no feature is enabled"
,
config
:
&
config
.
Config
{
GitlabUrl
:
"http+unix://gitlab.socket"
,
Migration
:
config
.
MigrationConfig
{
Enabled
:
false
},
...
...
@@ -48,8 +45,7 @@ func TestNew(t *testing.T) {
expectedType
:
&
fallback
.
Command
{},
},
{
desc
:
"it returns a TwoFactorRecover command if the feature is enabled"
,
arguments
:
[]
string
{},
desc
:
"it returns a TwoFactorRecover command if the feature is enabled"
,
config
:
&
config
.
Config
{
GitlabUrl
:
"http+unix://gitlab.socket"
,
Migration
:
config
.
MigrationConfig
{
Enabled
:
true
,
Features
:
[]
string
{
"2fa_recovery_codes"
}},
...
...
@@ -61,8 +57,7 @@ func TestNew(t *testing.T) {
expectedType
:
&
twofactorrecover
.
Command
{},
},
{
desc
:
"it returns a ReceivePack command if the feature is enabled"
,
arguments
:
[]
string
{},
desc
:
"it returns a ReceivePack command if the feature is enabled"
,
config
:
&
config
.
Config
{
GitlabUrl
:
"http+unix://gitlab.socket"
,
Migration
:
config
.
MigrationConfig
{
Enabled
:
true
,
Features
:
[]
string
{
"git-receive-pack"
}},
...
...
@@ -73,6 +68,18 @@ func TestNew(t *testing.T) {
},
expectedType
:
&
receivepack
.
Command
{},
},
{
desc
:
"it returns a Fallback command if the feature is unimplemented"
,
config
:
&
config
.
Config
{
GitlabUrl
:
"http+unix://gitlab.socket"
,
Migration
:
config
.
MigrationConfig
{
Enabled
:
true
,
Features
:
[]
string
{
"git-unimplemented-feature"
}},
},
environment
:
map
[
string
]
string
{
"SSH_CONNECTION"
:
"1"
,
"SSH_ORIGINAL_COMMAND"
:
"git-unimplemented-feature"
,
},
expectedType
:
&
fallback
.
Command
{},
},
}
for
_
,
tc
:=
range
testCases
{
...
...
@@ -80,7 +87,7 @@ func TestNew(t *testing.T) {
restoreEnv
:=
testhelper
.
TempEnv
(
tc
.
environment
)
defer
restoreEnv
()
command
,
err
:=
New
(
tc
.
arguments
,
tc
.
config
,
nil
)
command
,
err
:=
New
(
[]
string
{}
,
tc
.
config
,
nil
)
require
.
NoError
(
t
,
err
)
require
.
IsType
(
t
,
tc
.
expectedType
,
command
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment