Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
bbef82f4
Commit
bbef82f4
authored
Oct 20, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"enc" -> EncShort
parent
4986600e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
5 deletions
+11
-5
commands/command_test.go
commands/command_test.go
+2
-2
commands/option.go
commands/option.go
+7
-1
commands/response.go
commands/response.go
+1
-1
commands/response_test.go
commands/response_test.go
+1
-1
No files found.
commands/command_test.go
View file @
bbef82f4
...
...
@@ -57,7 +57,7 @@ func TestOptionValidation(t *testing.T) {
}
req
=
NewEmptyRequest
()
req
.
options
[
"enc"
]
=
"json"
req
.
options
[
EncShort
]
=
"json"
res
=
cmd
.
Call
(
req
)
if
res
.
Error
!=
nil
{
t
.
Error
(
"Should have passed"
)
...
...
@@ -110,7 +110,7 @@ func TestRegistration(t *testing.T) {
&
Command
{
Options
:
[]
Option
{
Option
{[]
string
{
"enc"
},
String
},
Option
{[]
string
{
EncShort
},
String
},
},
run
:
func
(
req
*
Request
,
res
*
Response
)
{},
},
...
...
commands/option.go
View file @
bbef82f4
...
...
@@ -22,9 +22,15 @@ type Option struct {
//Required bool // whether or not the option must be provided
}
// Flag names
const
(
EncShort
=
"enc"
EncLong
=
"encoding"
)
// options that are used by this package
var
globalOptions
=
[]
Option
{
Option
{[]
string
{
"enc"
,
"encodi
ng
"
},
String
},
Option
{[]
string
{
EncShort
,
EncLo
ng
},
String
},
}
// the above array of Options, wrapped in a Command
...
...
commands/response.go
View file @
bbef82f4
...
...
@@ -66,7 +66,7 @@ func (r *Response) Marshal() ([]byte, error) {
return
nil
,
fmt
.
Errorf
(
"No error or value set, there is nothing to marshal"
)
}
enc
,
ok
:=
r
.
req
.
Option
(
"enc"
)
enc
,
ok
:=
r
.
req
.
Option
(
EncShort
)
if
!
ok
||
enc
.
(
string
)
==
""
{
return
nil
,
fmt
.
Errorf
(
"No encoding type was specified"
)
}
...
...
commands/response_test.go
View file @
bbef82f4
...
...
@@ -30,7 +30,7 @@ func TestMarshalling(t *testing.T) {
t
.
Error
(
"Should have failed (no encoding type specified in request)"
)
}
req
.
SetOption
(
"enc"
,
JSON
)
req
.
SetOption
(
EncShort
,
JSON
)
req
.
convertOptions
(
options
)
bytes
,
err
:=
res
.
Marshal
()
...
...
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