Skip to content

Commit

Permalink
Implement FakeFixture in FakeClusterWeight for misk test
Browse files Browse the repository at this point in the history
injector reuse

GitOrigin-RevId: 7c739eecbde38ee4220e539a4c2f7dc3fe63b3a7
  • Loading branch information
rainecp authored and svc-squareup-copybara committed Nov 27, 2024
1 parent 335658e commit 60cfef6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion misk-clustering/api/misk-clustering.api
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public abstract interface class misk/clustering/weights/ClusterWeightProvider {
public abstract interface class misk/clustering/weights/ClusterWeightService : com/google/common/util/concurrent/Service {
}

public final class misk/clustering/weights/FakeClusterWeight : misk/clustering/weights/ClusterWeightProvider {
public final class misk/clustering/weights/FakeClusterWeight : misk/testing/FakeFixture, misk/clustering/weights/ClusterWeightProvider {
public fun <init> ()V
public fun get ()I
public final fun setClusterWeight (I)V
Expand Down
2 changes: 1 addition & 1 deletion misk-clustering/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
implementation(project(":misk-backoff"))
implementation(project(":misk-lease"))
implementation(project(":misk-service"))
implementation(project(":misk-testing-api"))
api(project(":misk-testing-api"))

testImplementation(libs.assertj)
testImplementation(libs.junitApi)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package misk.clustering.weights

import misk.inject.KAbstractModule
import misk.testing.FakeFixture
import misk.testing.TestFixture

/**
* A [ClusterWeightProvider] for testing
*/
class FakeClusterWeight : ClusterWeightProvider {
class FakeClusterWeight : ClusterWeightProvider, FakeFixture() {

private var weight = 100
private var weight by resettable { 100 }

override fun get(): Int {
return weight
Expand All @@ -25,6 +27,7 @@ class FakeClusterWeightModule : KAbstractModule() {
override fun configure() {
val fake = FakeClusterWeight()
bind<FakeClusterWeight>().toInstance(fake)
multibind<TestFixture>().to<FakeClusterWeight>()
bind<ClusterWeightProvider>().toInstance(fake)
install(NoOpClusterWeightServiceModule())
}
Expand Down

0 comments on commit 60cfef6

Please sign in to comment.