mirror of
https://github.com/clearlinux/mixer-tools.git
synced 2026-09-05 13:11:31 +00:00
Add more tests for manifest creation
Add two more tests for CreateManifests. One to test that the state flag is being set correctly for state files and another to test that empty directories are correctly added to the manifest. Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
@@ -398,3 +398,38 @@ func TestCreateManifestIncludeVersionBump(t *testing.T) {
|
||||
mustNotExist(t, filepath.Join(testDir, "www/30/Manifest.test-bundle"))
|
||||
mustNotExist(t, filepath.Join(testDir, "www/30/Manifest.included2"))
|
||||
}
|
||||
|
||||
func TestCreateManifestsState(t *testing.T) {
|
||||
testDir := mustSetupTestDir(t, "state")
|
||||
defer removeIfNoErrors(t, testDir)
|
||||
mustInitStandardTest(t, testDir, "0", "10", []string{})
|
||||
mustGenFile(t, testDir, "10", "os-core", "var/lib/test", "test")
|
||||
if err := CreateManifests(10, false, 1, testDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
re := regexp.MustCompile("D\\.s\\.\t.*\t10\t/var/lib\n")
|
||||
if fileContainsRe(filepath.Join(testDir, "www/10/Manifest.os-core"), re) == "" {
|
||||
t.Errorf("%v not found in 10/Manifest.os-core", re.String())
|
||||
}
|
||||
|
||||
re = regexp.MustCompile("F\\.s\\.\t.*\t10\t/var/lib/test\n")
|
||||
if fileContainsRe(filepath.Join(testDir, "www/10/Manifest.os-core"), re) == "" {
|
||||
t.Errorf("%v not found in 10/Manifest.os-core", re.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateManifestsEmptyDir(t *testing.T) {
|
||||
testDir := mustSetupTestDir(t, "emptydir")
|
||||
defer removeIfNoErrors(t, testDir)
|
||||
mustInitStandardTest(t, testDir, "0", "10", []string{})
|
||||
mustGenBundleDir(t, testDir, "10", "os-core", "emptydir")
|
||||
if err := CreateManifests(10, false, 1, testDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
re := regexp.MustCompile("D\\.\\.\\.\t.*\t10\t/emptydir\n")
|
||||
if fileContainsRe(filepath.Join(testDir, "www/10/Manifest.os-core"), re) == "" {
|
||||
t.Errorf("%v not found in 10/Manifest.os-core", re.String())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,11 @@ func removeIfNoErrors(t *testing.T, testDir string) {
|
||||
}
|
||||
}
|
||||
|
||||
func mustGenBundleDir(t *testing.T, testDir, ver, bundle, dirName string) {
|
||||
dirPath := filepath.Join(testDir, "image", ver, bundle, dirName)
|
||||
mustMkdir(t, dirPath)
|
||||
}
|
||||
|
||||
var serverINITemplate = template.Must(template.New("server.ini").Parse(`
|
||||
[Server]
|
||||
emptydir={{.testDir}}/empty/
|
||||
|
||||
Reference in New Issue
Block a user