-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdistrohandler_ubuntu_test.go
More file actions
56 lines (43 loc) · 1.71 KB
/
Copy pathdistrohandler_ubuntu_test.go
File metadata and controls
56 lines (43 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package imagecustomizerlib
import (
"os"
"path/filepath"
"testing"
"github.com/microsoft/azure-linux-image-tools/toolkit/tools/imagecustomizerapi"
"github.com/stretchr/testify/assert"
)
func TestCustomizeImageUbuntuUnsupportedAPIs(t *testing.T) {
for _, baseImageInfo := range baseImageUbuntuAll {
t.Run(baseImageInfo.Name, func(t *testing.T) {
testCustomizeImageUbuntuUnsupportedAPIsHelper(t, baseImageInfo)
})
}
}
func testCustomizeImageUbuntuUnsupportedAPIsHelper(t *testing.T, baseImageInfo testBaseImageInfo) {
baseImage := checkSkipForCustomizeImage(t, baseImageInfo)
testTmpDir := filepath.Join(tmpDir, "TestCustomizeImageUbuntuUnsupportedAPIs_"+baseImageInfo.Name)
defer os.RemoveAll(testTmpDir)
buildDir := filepath.Join(testTmpDir, "build")
options := ImageCustomizerOptions{
BuildDir: buildDir,
InputImageFile: baseImage,
OutputImageFile: "./out/image.vhdx",
OutputImageFormat: "vhdx",
UseBaseImageRpmRepos: true,
PreviewFeatures: baseImageInfo.PreviewFeatures,
}
config := &imagecustomizerapi.Config{
OS: &imagecustomizerapi.OS{},
}
config.OS.BootLoader.ResetType = imagecustomizerapi.ResetBootLoaderTypeHard
err := CustomizeImage(t.Context(), testTmpDir, config, options)
assert.ErrorIs(t, err, ErrUbuntuUnsupportedBootloaderHardReset)
assert.ErrorIs(t, err, ErrUnsupportedDistroApi)
config.OS.BootLoader.ResetType = imagecustomizerapi.ResetBootLoaderTypeDefault
options.UseBaseImageRpmRepos = false
err = CustomizeImage(t.Context(), testTmpDir, config, options)
assert.ErrorIs(t, err, ErrUbuntuUnsupportedDisableBaseImageRepos)
assert.ErrorIs(t, err, ErrUnsupportedDistroApi)
}