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:
Matthew Johnson
2018-01-05 16:16:56 -08:00
committed by tmarcu
parent a390c6a573
commit 7df6a2456e
2 changed files with 40 additions and 0 deletions
+35
View File
@@ -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())
}
}
+5
View File
@@ -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/