Skip to content

Commit 852f5fb

Browse files
committed
integrate client and server tests
1 parent 352be7d commit 852f5fb

File tree

10 files changed

+68
-23
lines changed

10 files changed

+68
-23
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
docker stop swagger-petstore 2> /dev/null
22
docker rm swagger-petstore 2> /dev/null
3+
docker pull swaggerapi/petstore:latest
34
docker run --rm -d --name swagger-petstore -e SWAGGER_HOST=http://127.0.0.1 -e SWAGGER_BASE_PATH=/v2 -p 8080:8080 swaggerapi/petstore:latest
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
echo "stopping swagger-petstore server"
12
docker stop swagger-petstore
23
docker rm swagger-petstore 2>/dev/null
4+
echo "stopped swagger-petstore server"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
docker stop openapi-petstore 2> /dev/null
22
docker rm openapi-petstore 2> /dev/null
3+
docker pull openapitools/openapi-petstore:latest
34
docker run --rm -d --name openapi-petstore -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 8081:8080 openapitools/openapi-petstore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
echo "stopping openapi-petstore server"
12
docker stop openapi-petstore
23
docker rm openapi-petstore 2>/dev/null
4+
echo "stopped openapi-petstore server"

test/client/runtests.jl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module OpenAPIClientTests
2+
13
using OpenAPI
24
using OpenAPI.Clients
35
using Test
@@ -6,22 +8,26 @@ include("utilstests.jl")
68
include("petstore_v3/runtests.jl")
79
include("petstore_v2/runtests.jl")
810

9-
@testset "Client" begin
10-
@testset "Utils" begin
11-
test_longpoll_exception_check()
12-
end
13-
@testset "Petstore" begin
14-
if get(ENV, "RUNNER_OS", "") == "Linux"
15-
@testset "V3" begin
16-
@info("Running petstore v3 tests")
17-
PetStoreV3Tests.runtests()
18-
end
19-
@testset "V2" begin
20-
@info("Running petstore v2 tests")
21-
PetStoreV2Tests.runtests()
11+
function runtests()
12+
@testset "Client" begin
13+
@testset "Utils" begin
14+
test_longpoll_exception_check()
15+
end
16+
@testset "Petstore" begin
17+
if get(ENV, "RUNNER_OS", "") == "Linux"
18+
@testset "V3" begin
19+
@info("Running petstore v3 tests")
20+
PetStoreV3Tests.runtests()
21+
end
22+
@testset "V2" begin
23+
@info("Running petstore v2 tests")
24+
PetStoreV2Tests.runtests()
25+
end
26+
else
27+
@info("Skipping petstore tests in non Linux environment (can not run petstore docker on OSX or Windows)")
2228
end
23-
else
24-
@info("Skipping petstore tests in non Linux environment (can not run petstore docker on OSX or Windows)")
2529
end
2630
end
2731
end
32+
33+
end # module OpenAPIClientTests

test/runtests.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Test
2+
3+
include("client/runtests.jl")
4+
5+
@testset "OpenAPI" begin
6+
@testset "Client" begin
7+
try
8+
run(`client/petstore_v2/start_petstore_server.sh`)
9+
run(`client/petstore_v3/start_petstore_server.sh`)
10+
sleep(20)
11+
OpenAPIClientTests.runtests()
12+
finally
13+
run(`client/petstore_v2/stop_petstore_server.sh`)
14+
run(`client/petstore_v3/stop_petstore_server.sh`)
15+
end
16+
end
17+
sleep(20)
18+
@testset "Server" begin
19+
try
20+
run(`server/petstore_v2/start_petstore_server.sh`)
21+
run(`server/petstore_v3/start_petstore_server.sh`)
22+
sleep(20)
23+
OpenAPIClientTests.runtests()
24+
finally
25+
run(`server/petstore_v2/stop_petstore_server.sh`)
26+
run(`server/petstore_v3/stop_petstore_server.sh`)
27+
end
28+
end
29+
end

test/server/petstore_v2/petstore_server.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module PetStoreImpl
1+
module PetStoreV2Server
22

33
using HTTP
44
using JSON
@@ -256,6 +256,6 @@ function run_server(port=8080)
256256
wait(server[])
257257
end
258258

259-
end # module PetStoreImpl
259+
end # module PetStoreV2Server
260260

261-
PetStoreImpl.run_server()
261+
PetStoreV2Server.run_server()
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/usr/bin/env bash
22

3-
curl "http://127.0.0.1:8080/stop"
3+
echo "stopping petstore v2 server"
4+
curl "http://127.0.0.1:8080/stop" >/dev/null 2>&1
5+
echo "stopped petstore v2 server"

test/server/petstore_v3/petstore_server.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module PetStoreImpl
1+
module PetStoreV3Server
22

33
using HTTP
44

@@ -255,6 +255,6 @@ function run_server(port=8081)
255255
wait(server[])
256256
end
257257

258-
end # module PetStoreImpl
258+
end # module PetStoreV3Server
259259

260-
PetStoreImpl.run_server()
260+
PetStoreV3Server.run_server()
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/usr/bin/env bash
22

3-
curl "http://127.0.0.1:8081/stop"
3+
echo "stopping petstore v3 server"
4+
curl "http://127.0.0.1:8081/stop" >/dev/null 2>&1
5+
echo "stopped petstore v3 server"

0 commit comments

Comments
 (0)