Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
c12072ec
Commit
c12072ec
authored
May 25, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: tests around interpolated names
parent
547d9e75
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
1 deletion
+49
-1
packer/core.go
packer/core.go
+1
-1
packer/core_test.go
packer/core_test.go
+42
-0
packer/test-fixtures/build-basic-interpolated.json
packer/test-fixtures/build-basic-interpolated.json
+6
-0
No files found.
packer/core.go
View file @
c12072ec
...
...
@@ -103,7 +103,7 @@ func (c *Core) BuildNames() []string {
// Build returns the Build object for the given name.
func
(
c
*
Core
)
Build
(
n
string
)
(
Build
,
error
)
{
// Setup the builder
configBuilder
,
ok
:=
c
.
template
.
Builder
s
[
n
]
configBuilder
,
ok
:=
c
.
build
s
[
n
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"no such build found: %s"
,
n
)
}
...
...
packer/core_test.go
View file @
c12072ec
...
...
@@ -78,6 +78,48 @@ func TestCoreBuild_basic(t *testing.T) {
}
}
func
TestCoreBuild_basicInterpolated
(
t
*
testing
.
T
)
{
config
:=
TestCoreConfig
(
t
)
testCoreTemplate
(
t
,
config
,
fixtureDir
(
"build-basic-interpolated.json"
))
b
:=
TestBuilder
(
t
,
config
,
"test"
)
core
:=
TestCore
(
t
,
config
)
b
.
ArtifactId
=
"hello"
build
,
err
:=
core
.
Build
(
"NAME"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
_
,
err
:=
build
.
Prepare
();
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
artifact
,
err
:=
build
.
Run
(
nil
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
len
(
artifact
)
!=
1
{
t
.
Fatalf
(
"bad: %#v"
,
artifact
)
}
if
artifact
[
0
]
.
Id
()
!=
b
.
ArtifactId
{
t
.
Fatalf
(
"bad: %s"
,
artifact
[
0
]
.
Id
())
}
}
func
TestCoreBuild_nonExist
(
t
*
testing
.
T
)
{
config
:=
TestCoreConfig
(
t
)
testCoreTemplate
(
t
,
config
,
fixtureDir
(
"build-basic.json"
))
TestBuilder
(
t
,
config
,
"test"
)
core
:=
TestCore
(
t
,
config
)
_
,
err
:=
core
.
Build
(
"nope"
)
if
err
==
nil
{
t
.
Fatal
(
"should error"
)
}
}
func
TestCoreValidate
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
File
string
...
...
packer/test-fixtures/build-basic-interpolated.json
0 → 100644
View file @
c12072ec
{
"builders"
:
[{
"name"
:
"{{upper `name`}}"
,
"type"
:
"test"
}]
}
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