-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(example): add Ksp Ktorfit plugin to test sourceSets (#404)
* fix(example): add Ksp Ktorfit plugin to test sourceSets, fix commonTest to support all platforms
- Loading branch information
1 parent
498bd91
commit dfa15d7
Showing
6 changed files
with
65 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
.../MultiplatformExample/shared/src/commonTest/kotlin/com/example/ktorfittest/KtorfitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.ktorfittest | ||
|
||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.launch | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class KtorfitTest { | ||
@Test | ||
fun test() { | ||
GlobalScope.launch { | ||
ktorfit.create<TestApi>() | ||
.getPersonByIdResponse(3) | ||
.collect { | ||
assertEquals(it.name, "R2-D2") | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
example/MultiplatformExample/shared/src/commonTest/kotlin/com/example/ktorfittest/TestApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.example.ktorfittest | ||
|
||
import de.jensklingenberg.ktorfit.http.GET | ||
import de.jensklingenberg.ktorfit.http.Path | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface TestApi { | ||
companion object { | ||
const val baseUrl = "https://swapi.dev/api/" | ||
} | ||
|
||
@GET("people/{id}/") | ||
suspend fun getPersonByIdResponse(@Path("id") peopleId: Int): Flow<Person> | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...e/MultiplatformExample/shared/src/macosX64Main/kotlin/com/example/ktorfittest/Platform.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.example.ktorfittest | ||
|
||
import platform.UIKit.UIDevice | ||
|
||
actual class Platform actual constructor() { | ||
actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion | ||
actual val platform: String = "macOS" | ||
} |