Skip to content

feat: correct autorun filter #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,6 @@ class PreferenceRepository(
}
}

fun isDescriptorEnabled(
descriptor: Descriptor,
isAutoRun: Boolean,
): Flow<Boolean> {
val key = getPreferenceKey(
name = descriptor.name,
prefix = (descriptor.source as? Descriptor.Source.Installed)
?.value?.id?.value?.toString(),
autoRun = isAutoRun,
)
return dataStore.data.map {
it[booleanPreferencesKey(key)] == true
}.distinctUntilChanged()
}

fun isNetTestEnabled(
descriptor: Descriptor,
netTest: NetTest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GetAutoRunSpecification(
}

private suspend fun List<Descriptor>.filterForAutoRun() =
filter { it.enabled && it.isEnabledForAutoRun() }
filter { it.enabled }
.map { descriptor ->
descriptor.copy(
netTests = descriptor.netTests
Expand All @@ -41,14 +41,6 @@ class GetAutoRunSpecification(
// We only want descriptors with any test left
.filter { it.netTests.any() || it.longRunningTests.any() }

private suspend fun Descriptor.isEnabledForAutoRun() =
if (name == "experimental") {
// Only the experimental descriptor has its own auto-run preference
preferenceRepository.isDescriptorEnabled(this, isAutoRun = true).first()
} else {
true
}

private suspend fun Descriptor.isEnabledForAutoRun(netTest: NetTest) =
preferenceRepository.isNetTestEnabled(this, netTest, isAutoRun = true).first()
}