Skip to content

Commit

Permalink
ignore random delay for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Jul 22, 2024
1 parent e933595 commit d9734a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Requires macOS 12.0 and higher.

### Fixed
- When a user clicked on the `updateDevice` button, the logs would incorrectly state the user was entering the "Unsupported UI" workflow.
- When running unit tests, Nudge no longer honors the randomDelay key or command line argument

### Added
- To ease SOFA testing, you can now pass `-custom-sofa-feed-url` as an argument to override the built-in preferences and/or custom profile/json.
Expand All @@ -24,6 +25,9 @@ Requires macOS 12.0 and higher.
## [2.0.1] - 2024-07-19
Requires macOS 12.0 and higher.

### Changed
- The command line argument `-disable-randomDelay` is now `-disable-random-delay`

### Fixed
- Some incorrect logic was applied to the `requiredInstallatonDate` when using the new `gracePeriodInstallDelay`
- https://github.com/macadmins/nudge/commit/61997a6137f1fd345a1314285cecc083f8674a15
Expand Down
2 changes: 1 addition & 1 deletion Nudge/UI/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

private func applyRandomDelayIfNecessary() {
if UserExperienceVariables.randomDelay && !CommandLine.arguments.contains("-disable-randomDelay") {
if UserExperienceVariables.randomDelay && !(CommandLineUtilities().disableRandomDelayArgumentPassed() || CommandLineUtilities().unitTestingEnabled()) {
let delaySeconds = Int.random(in: 1...UserExperienceVariables.maxRandomDelayInSeconds)
LogManager.notice("Delaying initial run (in seconds) by: \(delaySeconds)", logger: uiLog)

Expand Down
4 changes: 4 additions & 0 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ struct CommandLineUtilities {
return checkAndLogArgument("-demo-mode", logStateKey: &nudgeLogState.hasLoggedDemoMode)
}

func disableRandomDelayArgumentPassed() -> Bool {
return arguments.contains("-disable-random-delay")
}

func forceScreenShotIconModeEnabled() -> Bool {
return checkAndLogArgument("-force-screenshot-icon", logStateKey: &nudgeLogState.hasLoggedScreenshotIconMode)
}
Expand Down

0 comments on commit d9734a0

Please sign in to comment.