Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
required: true
default: '17'
os:
description: 'Operating System (ubuntu-22.04, ubuntu-latest, windows-latest)'
description: 'Operating System (ubuntu-latest, windows-latest)'
required: true
default: 'ubuntu-latest'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,14 @@ private static void scheduleSnapshotWatcher() {
* @return ScheduledFuture instance
*/
public static ScheduledFuture<?> scheduleSnapshotAutoUpdate(String intervalValue, SnapshotCallback callback) {
if (StringUtils.isBlank(intervalValue) || scheduledExecutorService != null) {
if (StringUtils.isBlank(intervalValue)) {
return null;
}

if (Objects.nonNull(scheduledExecutorService)) {
terminateSnapshotAutoUpdateWorker();
}

final long interval = SwitcherUtils.getMillis(intervalValue);
final SnapshotCallback callbackFinal = Optional.ofNullable(callback).orElse(new SnapshotCallback() {});
final Runnable runnableSnapshotValidate = () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,15 @@ void shouldNotKillThread_whenAPI_wentLocal() {

@Test
@Order(6)
void shouldPreventSnapshotAutoUpdateToStart_whenAlreadySetup() {
//given
void shouldRestartSnapshotAutoUpdate_whenAlreadySetup() {
//given - initialize (snapshot autoload)
givenResponse(generateMockAuth(10)); //auth
givenResponse(generateSnapshotResponse("default.json", SNAPSHOTS_LOCAL)); //graphql

//given - snapshot auto update
givenResponse(generateCheckSnapshotVersionResponse(Boolean.toString(false))); //criteria/snapshot_check
givenResponse(generateSnapshotResponse("default.json", SNAPSHOTS_LOCAL)); //graphql

//that
Switchers.configure(ContextBuilder.builder(true)
.context(Switchers.class.getCanonicalName())
Expand All @@ -235,8 +239,9 @@ void shouldPreventSnapshotAutoUpdateToStart_whenAlreadySetup() {
.snapshotAutoUpdateInterval("1s"));

Switchers.initializeClient();

ScheduledFuture<?> snapshotUpdater = Switchers.scheduleSnapshotAutoUpdate("1m");
assertNull(snapshotUpdater);
assertNotNull(snapshotUpdater);
}

}
Loading