tests: Fix tests
Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
This commit is contained in:
parent
dd35a5830b
commit
02148a5918
@ -19,11 +19,17 @@ var lxdDef = shared.Definition{
|
||||
Description: "{{ image.distribution|capfirst }} {{ image. release }}",
|
||||
Distribution: "ubuntu",
|
||||
Release: "17.10",
|
||||
Architecture: "amd64",
|
||||
Architecture: "x86_64",
|
||||
Expiry: "30d",
|
||||
Name: "{{ image.distribution|lower }}-{{ image.release }}-{{ image.architecture }}-{{ image.serial }}",
|
||||
Serial: "testing",
|
||||
},
|
||||
Source: shared.DefinitionSource{
|
||||
Downloader: "debootstrap",
|
||||
},
|
||||
Packages: shared.DefinitionPackages{
|
||||
Manager: "apt",
|
||||
},
|
||||
}
|
||||
|
||||
func setupLXD(t *testing.T) *LXDImage {
|
||||
@ -52,6 +58,14 @@ func setupLXD(t *testing.T) *LXDImage {
|
||||
t.Fatal("lxdDef and image.definition are not equal")
|
||||
}
|
||||
|
||||
lxdDef.SetDefaults()
|
||||
|
||||
err = lxdDef.Validate()
|
||||
if err != nil {
|
||||
teardownLXD(t)
|
||||
t.Fatalf("Failed to validate image: %s", err)
|
||||
}
|
||||
|
||||
return image
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
func TestSetDefinitionDefaults(t *testing.T) {
|
||||
def := Definition{}
|
||||
|
||||
SetDefinitionDefaults(&def)
|
||||
def.SetDefaults()
|
||||
|
||||
uname, _ := shared.Uname()
|
||||
|
||||
@ -187,7 +187,8 @@ func TestValidateDefinition(t *testing.T) {
|
||||
|
||||
for i, tt := range tests {
|
||||
log.Printf("Running test #%d: %s", i, tt.name)
|
||||
err := ValidateDefinition(tt.definition)
|
||||
tt.definition.SetDefaults()
|
||||
err := tt.definition.Validate()
|
||||
if !tt.shouldFail && err != nil {
|
||||
t.Fatalf("Validation failed: %s", err)
|
||||
} else if tt.shouldFail {
|
||||
|
Loading…
x
Reference in New Issue
Block a user