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
138c3951
Commit
138c3951
authored
May 03, 2015
by
Christian Couder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse_test: use fileToSimulateStdin()
License: MIT Signed-off-by:
Christian Couder
<
chriscool@tuxfamily.org
>
parent
4cdea68b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
cli/parse_test.go
cli/parse_test.go
+13
-7
No files found.
cli/parse_test.go
View file @
138c3951
...
...
@@ -229,15 +229,18 @@ func TestArgumentParsing(t *testing.T) {
}
// Use a temp file to simulate stdin
fileToSimulateStdin
:=
func
(
t
*
testing
.
T
,
content
string
)
(
*
os
.
File
)
{
fstdin
,
err
:=
ioutil
.
TempFile
(
""
,
""
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
os
.
Remove
(
fstdin
.
Name
())
if _, err := io.WriteString(fstdin,
"stdin1"
); err != nil {
if
_
,
err
:=
io
.
WriteString
(
fstdin
,
content
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
fstdin
}
test
:=
func
(
cmd
words
,
f
*
os
.
File
,
res
words
)
{
if
f
!=
nil
{
...
...
@@ -255,6 +258,9 @@ func TestArgumentParsing(t *testing.T) {
}
test
([]
string
{
"stdinenabled"
,
"value1"
,
"value2"
},
nil
,
[]
string
{
"value1"
,
"value2"
})
fstdin
:=
fileToSimulateStdin
(
t
,
"stdin1"
)
test
([]
string
{
"stdinenabled"
},
fstdin
,
[]
string
{
"stdin1"
})
test
([]
string
{
"stdinenabled"
,
"value1"
},
fstdin
,
[]
string
{
"stdin1"
,
"value1"
})
test
([]
string
{
"stdinenabled"
,
"value1"
,
"value2"
},
fstdin
,
[]
string
{
"stdin1"
,
"value1"
,
"value2"
})
...
...
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