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
bd6c31c2
Commit
bd6c31c2
authored
Jul 07, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added TestImageName and moved private methods to the bottom of the file
parent
eaf8550e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
39 deletions
+49
-39
builder/googlecompute/config_test.go
builder/googlecompute/config_test.go
+49
-39
No files found.
builder/googlecompute/config_test.go
View file @
bd6c31c2
...
...
@@ -2,48 +2,10 @@ package googlecompute
import
(
"io/ioutil"
"strings"
"testing"
)
func
testConfig
(
t
*
testing
.
T
)
map
[
string
]
interface
{}
{
return
map
[
string
]
interface
{}{
"account_file"
:
testAccountFile
(
t
),
"project_id"
:
"hashicorp"
,
"source_image"
:
"foo"
,
"zone"
:
"us-east-1a"
,
}
}
func
testConfigStruct
(
t
*
testing
.
T
)
*
Config
{
c
,
warns
,
errs
:=
NewConfig
(
testConfig
(
t
))
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
len
(
warns
))
}
if
errs
!=
nil
{
t
.
Fatalf
(
"bad: %#v"
,
errs
)
}
return
c
}
func
testConfigErr
(
t
*
testing
.
T
,
warns
[]
string
,
err
error
,
extra
string
)
{
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
==
nil
{
t
.
Fatalf
(
"should error: %s"
,
extra
)
}
}
func
testConfigOk
(
t
*
testing
.
T
,
warns
[]
string
,
err
error
)
{
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad: %s"
,
err
)
}
}
func
TestConfigPrepare
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
Key
string
...
...
@@ -181,6 +143,54 @@ func TestConfigDefaults(t *testing.T) {
}
}
func
TestImageName
(
t
*
testing
.
T
)
{
c
,
_
,
_
:=
NewConfig
(
testConfig
(
t
))
if
strings
.
Contains
(
c
.
ImageName
,
"{{timestamp}}"
)
{
t
.
Errorf
(
"ImageName should be interpolated; found %s"
,
c
.
ImageName
)
}
}
// Helper stuff below
func
testConfig
(
t
*
testing
.
T
)
map
[
string
]
interface
{}
{
return
map
[
string
]
interface
{}{
"account_file"
:
testAccountFile
(
t
),
"project_id"
:
"hashicorp"
,
"source_image"
:
"foo"
,
"zone"
:
"us-east-1a"
,
}
}
func
testConfigStruct
(
t
*
testing
.
T
)
*
Config
{
c
,
warns
,
errs
:=
NewConfig
(
testConfig
(
t
))
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
len
(
warns
))
}
if
errs
!=
nil
{
t
.
Fatalf
(
"bad: %#v"
,
errs
)
}
return
c
}
func
testConfigErr
(
t
*
testing
.
T
,
warns
[]
string
,
err
error
,
extra
string
)
{
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
==
nil
{
t
.
Fatalf
(
"should error: %s"
,
extra
)
}
}
func
testConfigOk
(
t
*
testing
.
T
,
warns
[]
string
,
err
error
)
{
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad: %s"
,
err
)
}
}
func
testAccountFile
(
t
*
testing
.
T
)
string
{
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
...
...
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