Skip to content

Commit

Permalink
IHRDS 3171 tester user should be able to change override (#873)
Browse files Browse the repository at this point in the history
* non test setting change should not care about last updated time

* add test

* update tests
  • Loading branch information
lofoyet authored Oct 11, 2023
1 parent fff1444 commit 3ac529d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ package model {
lastUpdated: Option[Instant] = None) {

def nonTestSettingsChangedFrom(that: Feature) =
copy(overrides = Map.empty, overrideEligibility = false) !=
that.copy(overrides = Map.empty, overrideEligibility = false)
copy(overrides = Map.empty, overrideEligibility = false, lastUpdated = None) !=
that.copy(overrides = Map.empty, overrideEligibility = false, lastUpdated = None)
}

sealed trait AssignmentTruthAt extends Serializable with Product
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.iheart.thomas
package abtest
package model

import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.matchers.should.Matchers

import java.time.Instant

class ModelSuite extends AnyFunSuiteLike with Matchers {

val existingFeatureConfig: Feature = Feature(
name = "test feature",
overrides = Map(
"user1" -> "control",
"user2" -> "treatment"
),
lastUpdated = Some(Instant.EPOCH)
)

test("a new feature config with new override should not trigger nonTestSettingsChangedFrom") {
val newConfig: Feature = Feature(
name = "test feature",
overrides = Map(
"user1" -> "treatment",
"user2" -> "control"
),
lastUpdated = None
)
existingFeatureConfig nonTestSettingsChangedFrom newConfig shouldBe false
}

test("a new feature config with new description should trigger nonTestSettingsChangedFrom") {
val newConfig: Feature = Feature(
name = "test feature",
description = Some("test description"),
overrides = Map(
"user1" -> "control",
"user2" -> "treatment"
),
lastUpdated = None
)
existingFeatureConfig nonTestSettingsChangedFrom newConfig shouldBe true
}

}

0 comments on commit 3ac529d

Please sign in to comment.