Skip to content

Commit

Permalink
* Add message for the failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ag-ramachandran committed Jan 15, 2024
1 parent d903dc2 commit 35e36ba
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ class KustoAzureFsSetupCacheTest extends AnyFunSuite {
}

test("testUpdateAndGetPrevNativeAzureFs") {
val now = Instant.now(Clock.systemUTC())
val dataToTest = Table(
("now", "expectedResult"),
("now", "checkIfRefreshNeeded", "Scenario"),
// Initial set is false for the flag, but refresh
(Instant.now(Clock.systemUTC()), true),
(now, true, "Initial set is false for the flag, but refresh"),
// The cache is expired, so it will be re-set.The checkIfRefreshNeeded will return false, but the state is already true.
(Instant.now(Clock.systemUTC()).minus(3 * KustoConstants.SparkSettingsRefreshMinutes, ChronoUnit.MINUTES), true),
(now.minus(3 * KustoConstants.SparkSettingsRefreshMinutes, ChronoUnit.MINUTES), true,
"The cache is expired, so it will be re-set.The checkIfRefreshNeeded will return false, but the state is already true."),
// This will be within the cache interval and also the flag is set to true
(Instant.now(Clock.systemUTC()).minus(KustoConstants.SparkSettingsRefreshMinutes / 2, ChronoUnit.MINUTES) , true),
(now.minus(KustoConstants.SparkSettingsRefreshMinutes / 2, ChronoUnit.MINUTES) , true,
"This will be within the cache interval and also the flag is set to true"),
)

forAll(dataToTest) { (now: Instant, expectedResult: Boolean) =>
forAll(dataToTest) { (now: Instant, checkIfRefreshNeeded: Boolean, scenario:String) =>
val actualResult = KustoAzureFsSetupCache.updateAndGetPrevNativeAzureFs(now)
actualResult shouldEqual expectedResult
assert(actualResult == checkIfRefreshNeeded, scenario)
actualResult shouldEqual checkIfRefreshNeeded
}
}

Expand Down

0 comments on commit 35e36ba

Please sign in to comment.