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
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class LicenseExecutorSpec extends AnyFlatSpec with Matchers {
licenseType = LicenseType.Pro,
features = Feature.values.toSet,
expiresAt = Some(Instant.now().plusSeconds(15 * 86400)),
metadata = Map("trial" -> "true")
trial = true
)
}
val executor = new LicenseExecutor(strategy = mkStrategy(trialManager))
Expand Down Expand Up @@ -302,7 +302,7 @@ class LicenseExecutorSpec extends AnyFlatSpec with Matchers {
licenseType = LicenseType.Pro,
features = Feature.values.toSet,
expiresAt = Some(Instant.parse("2026-07-08T23:59:59Z")),
metadata = Map("trial" -> "true")
trial = true
)
val executor = new LicenseExecutor(
strategy = mkStrategy(proManager, refreshResult = Right(trialKey))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ package object licensing {
metadata: Map[String, String] = Map.empty,
quota: Option[Quota] = None,
usage: Option[LicenseUsage] = None,
platform: Option[Platform] = None
platform: Option[Platform] = None,
trial: Boolean = false
) {

/** Whether this is a trial license (Pro trial via API key). */
def isTrial: Boolean = metadata.get("trial").contains("true")
def isTrial: Boolean = trial

/** Days remaining until expiration, or None if no expiry. Positive = not yet expired. */
def daysRemaining: Option[Long] = daysRemainingAt(java.time.Instant.now())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ class LicenseKeySpec extends AnyFlatSpec with Matchers {
key.metadata shouldBe empty
}

"isTrial" should "return true when trial metadata is set" in {
"isTrial" should "return true when trial field is set" in {
val key = LicenseKey(
id = "org-123",
licenseType = LicenseType.Pro,
features = Set(Feature.MaterializedViews),
expiresAt = Some(Instant.now().plus(Duration.ofDays(30))),
metadata = Map("trial" -> "true")
trial = true
)
key.isTrial shouldBe true
}
Expand All @@ -103,13 +103,12 @@ class LicenseKeySpec extends AnyFlatSpec with Matchers {
id = "org-123",
licenseType = LicenseType.Pro,
features = Set(Feature.MaterializedViews),
expiresAt = Some(Instant.now().plus(Duration.ofDays(365))),
metadata = Map("trial" -> "false")
expiresAt = Some(Instant.now().plus(Duration.ofDays(365)))
)
key.isTrial shouldBe false
}

it should "return false when trial metadata is absent" in {
it should "return false when trial defaults to false" in {
LicenseKey.Community.isTrial shouldBe false
}

Expand Down
Loading