Skip to content

Commit

Permalink
fix: Fix report when dryRun option is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrea committed Feb 14, 2022
1 parent 7313956 commit 0342dc1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
### Breaking changes

## [Unreleased]

### Fixed
- fix: Fix report when dryRun option is enabled

## [1.0.0-beta.3]
### Fixed
- fix: Use piexijs dump method to detect if file is really supported
Expand Down
2 changes: 2 additions & 0 deletions src/assistant/setDateToFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ function SetDates({
tracer.error(`${newFilePath}: Error writing Exif`, error.message);
await handleUnresolved();
}
} else {
report.modified(newFilePath, datesToSet, from);
}
};
}
Expand Down
28 changes: 27 additions & 1 deletion test/unit/assistant/setDate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ describe("setDate", () => {
});
});

describe("when is not supported", () => {
describe("when it is not supported", () => {
describe("when copyIfNotModified option is true", () => {
it("should copy the file if outputFolder is not the same in which the file is", async () => {
const spy = spyTracer("debug");
Expand Down Expand Up @@ -678,6 +678,32 @@ describe("setDate", () => {
expect(result.totals.before.path).toEqual(result.totals.after.path);
});
});

describe("When dryRun option is provided", () => {
it("should only report modifications withour modifying original file", async () => {
const spy = spyTracer("debug");
const fileName = "gorilla.JPG";
const newFileName = "2013-10-23.jpg";
const date = "2013:10:23 00:00:00";
await copyAssetToTempPath(fileName, newFileName);
const fileOrigin = tempPath(newFileName);

const result = await setDate(fileOrigin, {
dryRun: true,
});

expectLog(
`2013-10-23.jpg: Setting DateTimeOriginal and DateTimeDigitized to 2013-10-23 00:00:00, from file name`,
spy
);
expect(result.totals.before.withDate).toEqual(0);
expect(result.totals.after.withDate).toEqual(1);
expect(result.totals.after.copied).toEqual(0);
expect(result.totals.after.moved).toEqual(0);
expect(result.totals.after.modified).toEqual(1);
expect(result.totals.before.path).toEqual(result.totals.after.path);
});
});
});

describe("when fileName is a valid partial date and baseDate is provided", () => {
Expand Down

0 comments on commit 0342dc1

Please sign in to comment.