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
595eca0d
Commit
595eca0d
authored
Nov 08, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Fixed tests
parent
231e5360
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
response_test.go
response_test.go
+12
-3
No files found.
response_test.go
View file @
595eca0d
...
@@ -2,6 +2,7 @@ package commands
...
@@ -2,6 +2,7 @@ package commands
import
(
import
(
"fmt"
"fmt"
"strings"
"testing"
"testing"
)
)
...
@@ -36,17 +37,25 @@ func TestMarshalling(t *testing.T) {
...
@@ -36,17 +37,25 @@ func TestMarshalling(t *testing.T) {
t
.
Error
(
err
,
"Should have passed"
)
t
.
Error
(
err
,
"Should have passed"
)
}
}
output
:=
string
(
bytes
)
output
:=
string
(
bytes
)
if
output
!=
"{
\"
Foo
\"
:
\"
beep
\"
,
\"
Bar
\"
:
\"
boop
\"
,
\"
Baz
\"
:1337}"
{
if
removeWhitespace
(
output
)
!=
"{
\"
Foo
\"
:
\"
beep
\"
,
\"
Bar
\"
:
\"
boop
\"
,
\"
Baz
\"
:1337}"
{
t
.
Error
(
"Incorrect JSON output"
)
t
.
Error
(
"Incorrect JSON output"
)
}
}
res
.
SetError
(
fmt
.
Errorf
(
"
You broke something
!"
),
ErrClient
)
res
.
SetError
(
fmt
.
Errorf
(
"
Oops
!"
),
ErrClient
)
bytes
,
err
=
res
.
Marshal
()
bytes
,
err
=
res
.
Marshal
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
"Should have passed"
)
t
.
Error
(
"Should have passed"
)
}
}
output
=
string
(
bytes
)
output
=
string
(
bytes
)
if
output
!=
"{
\"
Message
\"
:
\"
You broke something!
\"
,
\"
Code
\"
:1}"
{
fmt
.
Println
(
removeWhitespace
(
output
))
if
removeWhitespace
(
output
)
!=
"{
\"
Message
\"
:
\"
Oops!
\"
,
\"
Code
\"
:1}"
{
t
.
Error
(
"Incorrect JSON output"
)
t
.
Error
(
"Incorrect JSON output"
)
}
}
}
}
func
removeWhitespace
(
input
string
)
string
{
input
=
strings
.
Replace
(
input
,
" "
,
""
,
-
1
)
input
=
strings
.
Replace
(
input
,
"
\t
"
,
""
,
-
1
)
input
=
strings
.
Replace
(
input
,
"
\n
"
,
""
,
-
1
)
return
strings
.
Replace
(
input
,
"
\r
"
,
""
,
-
1
)
}
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