use helper method for mandatory config

This commit is contained in:
Roman Tomjak 2020-07-16 17:41:56 +01:00
parent adf1e29459
commit a65157a91b
No known key found for this signature in database
GPG Key ID: BB29BA0B3501D719
1 changed files with 7 additions and 25 deletions

View File

@ -146,39 +146,21 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) {
} }
func TestAgentSetToFalse(t *testing.T) { func TestAgentSetToFalse(t *testing.T) {
// only the mandatory attributes are specified cfg := mandatoryConfig(t)
const config = `{ cfg["qemu_agent"] = false
"builders": [
{
"type": "proxmox",
"proxmox_url": "https://my-proxmox.my-domain:8006/api2/json",
"username": "apiuser@pve",
"password": "supersecret",
"iso_file": "local:iso/Fedora-Server-dvd-x86_64-29-1.2.iso",
"ssh_username": "root",
"node": "my-proxmox",
"qemu_agent": false
}
]
}`
tpl, err := template.Parse(strings.NewReader(config)) var c Config
if err != nil { warn, err := c.Prepare(cfg)
t.Fatal(err)
}
b := &Builder{}
_, warn, err := b.Prepare(tpl.Builders["proxmox"].Config)
if err != nil { if err != nil {
t.Fatal(err, warn) t.Fatal(err, warn)
} }
if b.config.Agent != false { if c.Agent != false {
t.Errorf("Expected Agent to be false, got %t", b.config.Agent) t.Errorf("Expected Agent to be false, got %t", c.Agent)
} }
} }
func TestNetworkAdapterPacketQueueSupport(t *testing.T) { func TestPacketQueueSupportForNetworkAdapters(t *testing.T) {
drivertests := []struct { drivertests := []struct {
expectedToFail bool expectedToFail bool
model string model string