Skip to content

Commit a6008a0

Browse files
committed
Add sttp tests on Native
1 parent 41c570b commit a6008a0

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

.github/workflows/test.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test examples
1+
name: Tests
22

33
on:
44
push:
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
test:
10-
name: Test examples
10+
name: Tests
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Check out code
@@ -26,6 +26,11 @@ jobs:
2626
- name: Check changelog compliance
2727
run: scala-cli changelog
2828

29+
- name: Install libidn2-dev libcurl3-dev for sttp on Native
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install libidn2-dev libcurl3-dev
33+
2934
- name: Run cross-platform tests
3035
run: scala-cli test tests/CrossPlatform.test.scala
3136

tests/native/RequestGet.sc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//> using dep com.softwaremill.sttp.client4::core::4.0.0-M14
2+
//> using platform native
3+
4+
import sttp.client4.quick.*
5+
6+
val request = quickRequest.get(uri"https://httpbin.org/get")
7+
val response = request.send()
8+
9+
val urlLine = response.body.linesIterator.find(_.contains("url")).get
10+
println(urlLine) //$ "url": "https://httpbin.org/get"

tests/native/RequestPost.sc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//> using toolkit default
2+
3+
import sttp.client4.quick.*
4+
5+
val response = quickRequest
6+
.post(uri"https://example.com/")
7+
.body("Lorem ipsum")
8+
.send()
9+
10+
val firstLines = response.body.linesIterator.take(4).mkString("\n")
11+
println(firstLines)
12+
//$ <!doctype html>
13+
//$ <html>
14+
//$ <head>
15+
//$ <title>Example Domain</title>

0 commit comments

Comments
 (0)