fileEntries, currentSnapshot);
}
@Test
public void updateCurrentSnapshotVersionNumberWhenUsingPinnedSnapshot() throws Exception {
DriftDefinition driftDef = driftDefinition("update-snapshot-version-pinned", resourceDir.getAbsolutePath());
driftDef.setPinned(true);
File confDir = mkdir(resourceDir, "conf");
File server1Conf = createRandomFile(confDir, "server1.conf");
DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftDef);
scheduleQueue.addSchedule(schedule);
detector.run();
// create some drift which should result in version 1
File server2Conf = createRandomFile(confDir, "server2.conf");
schedule.resetSchedule();
detector.run();
File currentSnapshot = changeSet(driftDef.getName(), COVERAGE);
File previousSnapshot = new File(currentSnapshot.getParentFile(), "changeset.txt.previous");
previousSnapshot.delete();
// create some more drift which should result in version 2
File server3Conf = createRandomFile(confDir, "server3.conf");
schedule.resetSchedule();
detector.run();
// verify that the current snapshot was updated
List<FileEntry> currentSnapshotEntries = asList(addedFileEntry("conf/server1.conf", sha256(server1Conf),
server1Conf.lastModified(), server1Conf.length()), addedFileEntry("conf/server2.conf", sha256(server2Conf),
server2Conf.lastModified(), server2Conf.length()), addedFileEntry("conf/server3.conf", sha256(server3Conf),
server3Conf.lastModified(), server3Conf.length()));
assertHeaderEquals(currentSnapshot, createHeaders(driftDef, COVERAGE, 2));
assertFileEntriesMatch("The current snapshot file should still get updated even when using a pinned snapshot",
currentSnapshotEntries, currentSnapshot);
// verify that the the drift/delta change set was generated
File driftChangeSet = changeSet(driftDef.getName(), DRIFT);
List<FileEntry> driftEntries = asList(addedFileEntry("conf/server2.conf", sha256(server2Conf), server2Conf
.lastModified(), server2Conf.length()), addedFileEntry("conf/server3.conf", sha256(server3Conf),
server3Conf.lastModified(), server3Conf.length()));
assertHeaderEquals(driftChangeSet, createHeaders(driftDef, DRIFT, 2));