-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KTOR-3420 Add integration tests for generating and running projects
- Loading branch information
1 parent
64ac1e7
commit 0969e9f
Showing
12 changed files
with
236 additions
and
91 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
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
Binary file not shown.
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
42 changes: 42 additions & 0 deletions
42
src/nativeMain/kotlin/io/ktor/generator/api/KtorWebGenerator.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,42 @@ | ||
package io.ktor.generator.api | ||
|
||
import io.ktor.client.* | ||
import io.ktor.client.request.* | ||
import io.ktor.generator.cli.installer.* | ||
import io.ktor.generator.cli.utils.* | ||
import io.ktor.generator.configuration.json.* | ||
import io.ktor.http.* | ||
|
||
interface KtorGeneratorWeb { | ||
/** | ||
* Downloads jdk archive and returns its byte content | ||
* */ | ||
suspend fun downloadJdkArchive(): ByteArray | ||
|
||
/** | ||
* Generates Ktor project and returns its byte content | ||
* */ | ||
suspend fun generateKtorProject(configuration: SelectedProjectConfiguration): ByteArray | ||
|
||
/** | ||
* Generates Ktor project and returns its byte content | ||
* */ | ||
suspend fun genProjectSettings(): ProjectSettingsTemplate | ||
} | ||
|
||
class KtorGeneratorWebImpl(val client: HttpClient, private val ktorBackendHost: String) : KtorGeneratorWeb { | ||
override suspend fun downloadJdkArchive(): ByteArray = client.fetchZipContent(jdkDownloadUrl) | ||
|
||
override suspend fun generateKtorProject(configuration: SelectedProjectConfiguration): ByteArray = | ||
client.fetchZipContent( | ||
"$ktorBackendHost/project/generate", | ||
httpMethod = HttpMethod.Post | ||
) { | ||
contentType(ContentType.Application.Json) | ||
|
||
body = configuration | ||
} | ||
|
||
override suspend fun genProjectSettings(): ProjectSettingsTemplate = | ||
client.get("$ktorBackendHost/project/settings") | ||
} |
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
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
Oops, something went wrong.