Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,10 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
cache: gradle

- name: Restore Gradle Cache
uses: actions/cache@v4
with:
path: |
./gradle/wrapper
.gradle/build-cache
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-

- name: Grant Execute Permission to Gradle Wrapper
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Run Gradle Checks and Tests
run: ./gradlew :gradle-plugin:processor:check --no-daemon --scan --stacktrace --build-cache
run: ./gradlew check --no-daemon --scan --stacktrace --build-cache
continue-on-error: true # Continue even if tests fail

- name: Upload Test Results
Expand Down Expand Up @@ -88,17 +75,8 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
cache: gradle

- name: Restore Gradle Cache
uses: actions/cache@v4
with:
path: |
./gradle/wrapper
.gradle/build-cache
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- id: get_version
name: Get version
uses: jannemattila/get-version-from-tag@v4
Expand Down
16 changes: 16 additions & 0 deletions e2e/polymorphism/src/test/kotlin/ClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import com.denisbrandi.netmock.NetMockRequest
import com.denisbrandi.netmock.NetMockResponseBuilder
import com.denisbrandi.netmock.engine.NetMockEngine
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.Json
import sample.client.Client
import sample.models.components.parameters.UserType
import sample.models.components.schemas.AdminUser.AdminUser
import sample.models.paths.users.get.response.GetUsersResponse200
import sample.models.paths.users.post.requestBody.PostUsersRequest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs
Expand Down Expand Up @@ -61,6 +63,20 @@ class ClientTest {
runCatching { client.getOrders(UserType.ADMIN) } // Will fail because it's mocked.
}

@Test
fun `post request body`() = runTest {
val request = PostUsersRequest()
interceptRequest(
"/users"
) {
assertEquals(
Json.encodeToString(request),
this.body
)
}
runCatching { client.postUsers(request) } // Response is not mocked, we only check request here.
}

private fun mockGet(relPath: String, response: String, status: Int = 200) {
netMock.addMockWithCustomMatcher(
requestMatcher = { interceptedRequest ->
Expand Down
22 changes: 22 additions & 0 deletions e2e/tvdb/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
kotlin("jvm")
kotlin("plugin.serialization")
alias(libs.plugins.local.plugin)
}

val input = "${project.projectDir}/src/test/resources/swagger.yml"

dependencies {
implementation(libs.serial)
implementation(libs.bundles.ktor)
testImplementation(kotlin("test"))
testImplementation(libs.coroutines.test)
}

openapi3 {
generators {
create("tvdb") {
inputSpec.set(layout.projectDirectory.file("src/test/resources/swagger.yml"))
}
}
}
26 changes: 26 additions & 0 deletions e2e/tvdb/src/test/kotlin/TestTvDb.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import io.ktor.client.engine.cio.CIO
import kotlinx.coroutines.test.runTest
import tvdb.client.Client
import tvdb.client.Servers
import tvdb.models.paths.login.post.requestBody.PostLoginRequest
import tvdb.models.paths.login.post.response.PostLoginResponse401
import kotlin.test.Test
import kotlin.test.assertIs
import kotlin.test.fail

class TestTvDb {


@Test
fun `try to make request`() = runTest {
val client = Client(CIO)
val response = client.postLogin(PostLoginRequest("weewewfweewf"))

try {
response.dataOrThrow()
fail("Request succeeded without apikey. Something is wrong.")
} catch (e: PostLoginResponse401) {

}
}
}
Loading
Loading