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-dms3-cmds
Commits
cf7b8bc6
Commit
cf7b8bc6
authored
Dec 12, 2017
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test case for #45
parent
2f6fa4eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
http/parse_test.go
http/parse_test.go
+47
-0
No files found.
http/parse_test.go
0 → 100644
View file @
cf7b8bc6
package
http
import
(
"net/http"
"testing"
cmds
"github.com/ipfs/go-ipfs-cmds"
)
func
TestParse
(
t
*
testing
.
T
)
{
root
:=
&
cmds
.
Command
{
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"block"
:
&
cmds
.
Command
{
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"put"
:
&
cmds
.
Command
{
Run
:
func
(
req
cmds
.
Request
,
resp
cmds
.
ResponseEmitter
)
{
defer
resp
.
Close
()
resp
.
Emit
(
"done"
)
},
},
},
},
},
}
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/api/v0/block/put"
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
req
,
err
:=
Parse
(
r
,
root
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
pth
:=
req
.
Path
()
if
pth
[
0
]
!=
"block"
||
pth
[
1
]
!=
"put"
||
len
(
pth
)
!=
2
{
t
.
Errorf
(
"incorrect path %v, expected %v"
,
pth
,
[]
string
{
"block"
,
"put"
})
}
r
,
err
=
http
.
NewRequest
(
"GET"
,
"/api/v0/block/bla"
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
req
,
err
=
Parse
(
r
,
root
)
if
err
!=
ErrNotFound
{
t
.
Errorf
(
"expected ErrNotFound, got: %v"
,
err
)
}
}
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