From 72b4189f76accaddd5aeab8923bfef3316d5b46a Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 3 Jul 2022 17:34:11 +0800 Subject: [PATCH] add back elixir petstore test-related files --- .../petstore/elixir/.openapi-generator/FILES | 1 - samples/client/petstore/elixir/pom.xml | 75 +++++++++++++++++++ .../client/petstore/elixir/test/pet_test.exs | 60 +++++++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 samples/client/petstore/elixir/pom.xml create mode 100644 samples/client/petstore/elixir/test/pet_test.exs diff --git a/samples/client/petstore/elixir/.openapi-generator/FILES b/samples/client/petstore/elixir/.openapi-generator/FILES index c08711e0374..d3fc3588109 100644 --- a/samples/client/petstore/elixir/.openapi-generator/FILES +++ b/samples/client/petstore/elixir/.openapi-generator/FILES @@ -1,6 +1,5 @@ .formatter.exs .gitignore -.openapi-generator-ignore README.md config/config.exs config/runtime.exs diff --git a/samples/client/petstore/elixir/pom.xml b/samples/client/petstore/elixir/pom.xml new file mode 100644 index 00000000000..589db62d2dc --- /dev/null +++ b/samples/client/petstore/elixir/pom.xml @@ -0,0 +1,75 @@ + + 4.0.0 + io.swagger + ElixirPetstoreClientTests + pom + 1.0-SNAPSHOT + Elixir Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + dep-install + pre-integration-test + + exec + + + mix + + local.hex + --force + + + + + compile + integration-test + + exec + + + mix + + do + deps.get, + compile + + + + + test + integration-test + + exec + + + mix + + test + + + + + + + + diff --git a/samples/client/petstore/elixir/test/pet_test.exs b/samples/client/petstore/elixir/test/pet_test.exs new file mode 100644 index 00000000000..6011a08ccf5 --- /dev/null +++ b/samples/client/petstore/elixir/test/pet_test.exs @@ -0,0 +1,60 @@ +defmodule PetTest do + use ExUnit.Case + alias OpenapiPetstore.Connection + alias OpenapiPetstore.Api.Pet, as: PetApi + alias OpenapiPetstore.Model.Pet + alias OpenapiPetstore.Model.Category + alias OpenapiPetstore.Model.Tag + + test "add and delete a pet" do + petId = 10007 + pet = %Pet{ + :id => petId, + :name => "elixir client test", + :photoUrls => ["http://test_elixir_unit_test.com"], + :category => %Category{:id => petId, :name=> "test elixir category"}, + :tags => [%Tag{:id => petId, :name => "test elixir tag"}], + } + {:ok, response} = PetApi.add_pet(Connection.new, pet) + assert response.status == 200 + + {:ok, pet} = PetApi.get_pet_by_id(Connection.new, petId) + assert pet.id == petId + assert pet.name == "elixir client test" + assert List.first(pet.photoUrls) == "http://test_elixir_unit_test.com" + assert pet.category.id == petId + assert pet.category.name == "test elixir category" + assert List.first(pet.tags) == %Tag{:id => petId, :name => "test elixir tag"} + + {:ok, response} = PetApi.delete_pet(Connection.new, petId) + assert response.status == 200 + {:ok, response} = PetApi.get_pet_by_id(Connection.new, petId) + assert response.status == 404 + end + + test "update a pet" do + petId = 10007 + pet = %Pet{ + :id => petId, + :name => "elixir client updatePet", + :status => "pending", + :photoUrls => ["http://test_elixir_unit_test.com"] + } + {:ok, response} = PetApi.update_pet(Connection.new, pet) + assert response.status == 200 + + {:ok, pet} = PetApi.get_pet_by_id(Connection.new, petId) + assert pet.id == petId + assert pet.name == "elixir client updatePet" + assert pet.status == "pending" + end + + test "find pet by status" do + {:ok, listPets} = PetApi.find_pets_by_status(Connection.new, "available") + assert List.first(listPets) != nil + + {:ok, listPets} = PetApi.find_pets_by_status(Connection.new, "unknown_and_incorrect_status") + assert List.first(listPets) == nil + end + +end