Skip to content

Commit

Permalink
Fix platform permutation logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
awaitlink committed Mar 11, 2024
1 parent c60cb30 commit fc266ca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ pub fn platforms_order(

let permutation_count = all_platforms.len().factorial();

let index: usize = (time.minute() / 10)
let index: usize = time
.minute()
.try_into()
.context("should be able to convert to usize")?;

let index = index % permutation_count;

let platforms = permute::permutations_of(all_platforms)
.nth(index)
.context("there should be >= 6 permutations")?
.context("there must be enough permutations")?
.copied()
.collect::<Vec<_>>();

Expand All @@ -71,7 +72,9 @@ mod tests {

use super::*;

#[test_case(&Platform::iter().collect::<Vec<Platform>>(), 6; "all")]
#[test_case(&Platform::iter().collect::<Vec<Platform>>(), 24; "all")]
#[test_case(&[Platform::Android, Platform::Ios, Platform::Desktop, Platform::Server], 24; "four")]
#[test_case(&[Platform::Android, Platform::Ios, Platform::Desktop], 6; "three")]
#[test_case(&[Platform::Android, Platform::Ios], 2; "two")]
#[test_case(&[Platform::Android], 1; "one")]
#[test_case(&[], 1; "none")]
Expand Down

0 comments on commit fc266ca

Please sign in to comment.