net: pin the user agent value and test the shared client

Build the shared OkHttpClient through UserAgent.httpClient() so the unit test exercises the same client the app uses, assert the exact 'Subtracks (Android; <version>)' value rather than the property it writes, and run the test under the Android runner.
This commit is contained in:
austinried
2026-10-09 06:33:22 +00:00
parent 92c6f6945f
commit 2439368e4e
3 changed files with 14 additions and 7 deletions
@@ -9,12 +9,11 @@ import com.subtracks.data.prefs.UserPreferences
import com.subtracks.data.repo.ArtworkSeedStore
import com.subtracks.di.appModule
import com.subtracks.ui.theme.ArtworkSeedCache
import okhttp3.OkHttpClient
import org.koin.core.context.startKoin
import org.koin.core.context.stopKoin
class SubtracksApp : Application() {
private val http = OkHttpClient.Builder().addInterceptor(UserAgent.interceptor()).build()
private val http = UserAgent.httpClient()
@OptIn(DelicateCoilApi::class)
override fun onCreate() {
@@ -1,6 +1,7 @@
package com.subtracks
import okhttp3.Interceptor
import okhttp3.OkHttpClient
object UserAgent {
val value: String = "Subtracks (Android; ${BuildConfig.VERSION_NAME})"
@@ -15,4 +16,6 @@ object UserAgent {
.build(),
)
}
fun httpClient(): OkHttpClient = OkHttpClient.Builder().addInterceptor(interceptor()).build()
}