Skip to content

Commit 60cfef6

Browse files
rainecpsvc-squareup-copybara
authored andcommitted
Implement FakeFixture in FakeClusterWeight for misk test
injector reuse GitOrigin-RevId: 7c739eecbde38ee4220e539a4c2f7dc3fe63b3a7
1 parent 335658e commit 60cfef6

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

misk-clustering/api/misk-clustering.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public abstract interface class misk/clustering/weights/ClusterWeightProvider {
223223
public abstract interface class misk/clustering/weights/ClusterWeightService : com/google/common/util/concurrent/Service {
224224
}
225225

226-
public final class misk/clustering/weights/FakeClusterWeight : misk/clustering/weights/ClusterWeightProvider {
226+
public final class misk/clustering/weights/FakeClusterWeight : misk/testing/FakeFixture, misk/clustering/weights/ClusterWeightProvider {
227227
public fun <init> ()V
228228
public fun get ()I
229229
public final fun setClusterWeight (I)V

misk-clustering/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222
implementation(project(":misk-backoff"))
2323
implementation(project(":misk-lease"))
2424
implementation(project(":misk-service"))
25-
implementation(project(":misk-testing-api"))
25+
api(project(":misk-testing-api"))
2626

2727
testImplementation(libs.assertj)
2828
testImplementation(libs.junitApi)

misk-clustering/src/main/kotlin/misk/clustering/weights/FakeClusterWeight.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package misk.clustering.weights
22

33
import misk.inject.KAbstractModule
4+
import misk.testing.FakeFixture
5+
import misk.testing.TestFixture
46

57
/**
68
* A [ClusterWeightProvider] for testing
79
*/
8-
class FakeClusterWeight : ClusterWeightProvider {
10+
class FakeClusterWeight : ClusterWeightProvider, FakeFixture() {
911

10-
private var weight = 100
12+
private var weight by resettable { 100 }
1113

1214
override fun get(): Int {
1315
return weight
@@ -25,6 +27,7 @@ class FakeClusterWeightModule : KAbstractModule() {
2527
override fun configure() {
2628
val fake = FakeClusterWeight()
2729
bind<FakeClusterWeight>().toInstance(fake)
30+
multibind<TestFixture>().to<FakeClusterWeight>()
2831
bind<ClusterWeightProvider>().toInstance(fake)
2932
install(NoOpClusterWeightServiceModule())
3033
}

0 commit comments

Comments
 (0)