EitherNet Versions Save

A pluggable sealed API result type for modeling Retrofit responses.

1.2.1

10 months ago
  • Update to Kotlin 1.6.10.
  • Promote test-fixtures APIs to stable.
  • Update kotlinx-coroutines to 1.6.0 (test-fixtures only)
  • Fix: test-fixtures artifact module metadata using the wrong artifact ID. They should correctly resolve when using Gradle's testFixtures(...) syntax.

1.2.0

1 year ago
  • Update to Kotlin 1.6.0
  • New: Directly instantiate intermediate EitherNet annotations. This is an internal change only.

1.1.0

1 year ago
  • Update Kotlin to 1.5.31
  • New: This release introduces a new EitherNetController API for testing EitherNet APIs via Test Fixtures. This is similar to OkHttp’s MockWebServer, where results can be enqueued for specific endpoints.

Simply create a new controller instance in your test using one of the newEitherNetController() functions.

val controller = newEitherNetController<PandaApi>() // reified type

Then you can access the underlying faked api property from it and pass that on to whatever’s being tested.

// Take the api instance from the controller and pass it to whatever's being tested
val provider = PandaDataProvider(controller.api)

Finally, enqueue results for endpoints as needed.

// Later in a test you can enqueue results for specific endpoints
controller.enqueue(PandaApi::getPandas, ApiResult.success("Po"))

You can also optionally pass in full suspend functions if you need dynamic behavior

controller.enqueue(PandaApi::getPandas) {
  // This is a suspend function!
  delay(1000)
  ApiResult.success("Po")
}

See its section in our README for full more details.

1.0.0

1 year ago

Stable release!

  • Fix: Embed proguard rules to keep relevant generics information on ApiResult. This is important for new versions of R8, which otherwise strips this information.
  • Fix: Require ApiResult type arguments to be non-null (i.e. T : Any).
  • New: Add a tags API for breadcrumbing information in ApiResult. We expose a few APIs through here, namely the original OkHttp Request or Response instances when relevant.
  • ApiResult subtypes are no longer data classes since many of their underlying properties don't reliably implement equals/hashCode/immutability.
  • The deprecated ApiResult.response property is now removed.

Thanks to @okamayana for contributing to this release!

1.0.0-rc01

1 year ago

This is our first (and hopefully final!) 1.0 release candidate. Please report any issues or API surface area issues now or forever hold your peace.

Note that we consider this stable for production use, this is mostly about API stability.

  • Breaking: ApiResult and ApiResult.Failure are both now sealed interface types rather than sealed classes. For most consumers this shouldn't be a source breaking change!
  • Breaking: ApiResult.Success constructor is now internal, please use the ApiResult.success(<value>) factory.
  • Test up to JDK 17.

Updated dependencies

Kotlin      1.5.21
Coroutines  1.5.1
Dokka       1.5.0

Special thanks to @danieldisu and @JvmName for contributing to this release!