Skip to content

Commit d9734a0

Browse files
committed
ignore random delay for unit tests
1 parent e933595 commit d9734a0

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Requires macOS 12.0 and higher.
99

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

1314
### Added
1415
- 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.
@@ -24,6 +25,9 @@ Requires macOS 12.0 and higher.
2425
## [2.0.1] - 2024-07-19
2526
Requires macOS 12.0 and higher.
2627

28+
### Changed
29+
- The command line argument `-disable-randomDelay` is now `-disable-random-delay`
30+
2731
### Fixed
2832
- Some incorrect logic was applied to the `requiredInstallatonDate` when using the new `gracePeriodInstallDelay`
2933
- https://github.com/macadmins/nudge/commit/61997a6137f1fd345a1314285cecc083f8674a15

Nudge/UI/Main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
357357
}
358358

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

Nudge/Utilities/Utils.swift

+4
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ struct CommandLineUtilities {
378378
return checkAndLogArgument("-demo-mode", logStateKey: &nudgeLogState.hasLoggedDemoMode)
379379
}
380380

381+
func disableRandomDelayArgumentPassed() -> Bool {
382+
return arguments.contains("-disable-random-delay")
383+
}
384+
381385
func forceScreenShotIconModeEnabled() -> Bool {
382386
return checkAndLogArgument("-force-screenshot-icon", logStateKey: &nudgeLogState.hasLoggedScreenshotIconMode)
383387
}

0 commit comments

Comments
 (0)