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 <otavio.pontes@intel.com>
This commit is contained in:
Otavio Pontes
2018-11-30 13:27:39 -08:00
committed by tmarcu
parent bc38cf5c3a
commit 2e70c7f989
+20
View File
@@ -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)