Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Packer
Commits
fd3cc596
Commit
fd3cc596
authored
4 years ago
by
Wilken Rivera
Browse files
Options
Download
Email Patches
Plain Diff
The original approach of running version, but that seems to bypass wrappedMain entirely
parent
708f9cdf
example-test
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
command/exec_test.go
+2
-0
command/exec_test.go
command/version_test.go
+26
-0
command/version_test.go
with
28 additions
and
0 deletions
+28
-0
command/exec_test.go
+
2
-
0
View file @
fd3cc596
...
...
@@ -95,6 +95,8 @@ func TestHelperProcess(*testing.T) {
os
.
Exit
((
&
BuildCommand
{
Meta
:
commandMeta
()})
.
Run
(
args
))
case
"hcl2_upgrade"
:
os
.
Exit
((
&
HCL2UpgradeCommand
{
Meta
:
commandMeta
()})
.
Run
(
args
))
case
"version"
:
os
.
Exit
((
&
VersionCommand
{
Meta
:
commandMeta
()})
.
Run
(
args
))
default
:
fmt
.
Fprintf
(
os
.
Stderr
,
"Unknown command %q
\n
"
,
cmd
)
os
.
Exit
(
2
)
...
...
This diff is collapsed.
Click to expand it.
command/version_test.go
+
26
-
0
View file @
fd3cc596
package
command
import
(
"fmt"
"testing"
"github.com/hashicorp/packer/version"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/assert"
)
func
TestVersionCommand_implements
(
t
*
testing
.
T
)
{
var
_
cli
.
Command
=
&
VersionCommand
{}
}
func
Test_version
(
t
*
testing
.
T
)
{
tc
:=
[]
struct
{
command
[]
string
env
[]
string
expected
string
}{
{[]
string
{
"version"
},
nil
,
fmt
.
Sprintf
(
"Packer v%s"
,
version
.
FormattedVersion
())
+
"
\n
"
},
{[]
string
{
"version"
,
"&"
},
nil
,
fmt
.
Sprintf
(
"Packer v%s"
,
version
.
FormattedVersion
())
+
"
\n
"
},
}
for
_
,
tc
:=
range
tc
{
t
.
Run
(
fmt
.
Sprintf
(
"packer %s"
,
tc
.
command
),
func
(
t
*
testing
.
T
)
{
p
:=
helperCommand
(
t
,
tc
.
command
...
)
bs
,
err
:=
p
.
Output
()
fmt
.
Println
(
err
)
if
err
!=
nil
{
t
.
Fatalf
(
"%v: %s"
,
err
,
bs
)
}
assert
.
Equal
(
t
,
tc
.
expected
,
string
(
bs
))
})
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help