diff --git a/swupd/create_manifests_test.go b/swupd/create_manifests_test.go index 9d29ee3..7bed328 100644 --- a/swupd/create_manifests_test.go +++ b/swupd/create_manifests_test.go @@ -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()) + } +} diff --git a/swupd/helpers_test.go b/swupd/helpers_test.go index 3b0c901..a6e3c54 100644 --- a/swupd/helpers_test.go +++ b/swupd/helpers_test.go @@ -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/