Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add kotlin("test") to commonTest #18

Open
wants to merge 1 commit into
base: okcurl
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions okcurl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ plugins {
}

kotlin {
jvm {
withJava()
}
jvm()

sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
}

val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting {
kotlin.srcDir("$buildDir/generated/resources-templates")

Expand All @@ -36,11 +39,8 @@ kotlin {

val jvmTest by getting {
dependencies {
dependsOn(jvmMain)
implementation(projects.okhttpTestingSupport)
api(libs.squareup.okio)
implementation(libs.kotlin.test.common)
implementation(libs.kotlin.test.annotations)
api(libs.assertk)
}
}
Expand Down
21 changes: 10 additions & 11 deletions okcurl/src/jvmTest/kotlin/okhttp3/curl/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,26 @@ import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isNull
import assertk.assertions.startsWith
//import kotlin.test.Test
//import kotlin.test.fail
import kotlin.test.Test

class MainTest {
// @Test
@Test
fun simple() {
val request = fromArgs("http://example.com").createRequest()
assertThat(request.method).isEqualTo("GET")
assertThat(request.url.toString()).isEqualTo("http://example.com/")
assertThat(request.body).isNull()
}

// @Test
@Test
@Throws(IOException::class) fun put() {
val request = fromArgs("-X", "PUT", "-d", "foo", "http://example.com").createRequest()
assertThat(request.method).isEqualTo("PUT")
assertThat(request.url.toString()).isEqualTo("http://example.com/")
assertThat(request.body!!.contentLength()).isEqualTo(3)
}

// @Test
@Test
fun dataPost() {
val request = fromArgs("-d", "foo", "http://example.com").createRequest()
val body = request.body
Expand All @@ -54,7 +53,7 @@ class MainTest {
assertThat(bodyAsString(body)).isEqualTo("foo")
}

// @Test
@Test
fun dataPut() {
val request = fromArgs("-d", "foo", "-X", "PUT", "http://example.com").createRequest()
val body = request.body
Expand All @@ -66,7 +65,7 @@ class MainTest {
assertThat(bodyAsString(body)).isEqualTo("foo")
}

// @Test
@Test
fun contentTypeHeader() {
val request = fromArgs(
"-d", "foo", "-H", "Content-Type: application/json",
Expand All @@ -80,7 +79,7 @@ class MainTest {
assertThat(bodyAsString(body)).isEqualTo("foo")
}

// @Test
@Test
fun referer() {
val request = fromArgs("-e", "foo", "http://example.com").createRequest()
assertThat(request.method).isEqualTo("GET")
Expand All @@ -89,7 +88,7 @@ class MainTest {
assertThat(request.body).isNull()
}

// @Test
@Test
fun userAgent() {
val request = fromArgs("-A", "foo", "http://example.com").createRequest()
assertThat(request.method).isEqualTo("GET")
Expand All @@ -98,13 +97,13 @@ class MainTest {
assertThat(request.body).isNull()
}

// @Test
@Test
fun defaultUserAgent() {
val request = fromArgs("http://example.com").createRequest()
assertThat(request.header("User-Agent")!!).startsWith("okcurl/")
}

// @Test
@Test
fun headerSplitWithDate() {
val request = fromArgs(
"-H", "If-Modified-Since: Mon, 18 Aug 2014 15:16:06 GMT",
Expand Down