From 2e70c7f989d09bb67f7710d9e91c863c4fa4e40d Mon Sep 17 00:00:00 2001 From: Otavio Pontes Date: Fri, 14 Sep 2018 13:34:54 -0700 Subject: [PATCH] test: Add function to check the number of files in a Manifest This function can be used to check if Iterative don't have more items that them should. Signed-off-by: Otavio Pontes --- swupd/helpers_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/swupd/helpers_test.go b/swupd/helpers_test.go index b883e33..3877724 100644 --- a/swupd/helpers_test.go +++ b/swupd/helpers_test.go @@ -189,6 +189,26 @@ func mustCreateManifests(t *testing.T, ver uint32, minVer uint32, format uint, t return mom } +func checkManifestFileCount(ts *testSwupd, version, manifest string, files, deleted int) { + + manifestFile := filepath.Join(ts.Dir, "www", version, "Manifest."+manifest) + m, err := ParseManifestFile(manifestFile) + if err != nil { + ts.t.Fatalf("Couldn't parse manifest %s: %s", manifestFile, err) + } + if len(m.Files) != files { + ts.t.Fatalf( + "Number of files in Manifest %s: %d is different from the expected: %d.", + manifestFile, len(m.Files), files) + } + + if len(m.DeletedFiles) != deleted { + ts.t.Fatalf( + "Number of deleted files in Manifest %s: %d is different from the expected: %d.", + manifestFile, len(m.DeletedFiles), deleted) + } +} + func checkManifestContains(t *testing.T, testDir, ver, name string, subs ...string) { t.Helper() manFpath := filepath.Join(testDir, "www", ver, "Manifest."+name)