Skip to content

Instantly share code, notes, and snippets.

@cdmunoz
Created September 4, 2020 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdmunoz/64c0669d6572eb2dafbe1caa0a23f0de to your computer and use it in GitHub Desktop.
Save cdmunoz/64c0669d6572eb2dafbe1caa0a23f0de to your computer and use it in GitHub Desktop.
Koin's test network module
fun testNetworkModule(baseUrl: String) = module {
single { provideTestRetrofit(baseUrl) }
single { provideTestApiService(get(), ApiService::class.java) }
}
fun provideTestRetrofit(baseUrl: String): Retrofit =
Retrofit.Builder().baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create()).build()
fun provideTestApiService(retrofit: Retrofit, apiService: Class<ApiService>) =
createService(retrofit, apiService)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment