forked from loafle/openapi-generator-original
add back elixir petstore test-related files
This commit is contained in:
parent
18a07eab37
commit
72b4189f76
@ -1,6 +1,5 @@
|
||||
.formatter.exs
|
||||
.gitignore
|
||||
.openapi-generator-ignore
|
||||
README.md
|
||||
config/config.exs
|
||||
config/runtime.exs
|
||||
|
75
samples/client/petstore/elixir/pom.xml
Normal file
75
samples/client/petstore/elixir/pom.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>ElixirPetstoreClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Elixir Petstore Client</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>dep-install</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>mix</executable>
|
||||
<arguments>
|
||||
<argument>local.hex</argument>
|
||||
<argument>--force</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>mix</executable>
|
||||
<arguments>
|
||||
<argument>do</argument>
|
||||
<argument>deps.get,</argument>
|
||||
<argument>compile</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>mix</executable>
|
||||
<arguments>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
60
samples/client/petstore/elixir/test/pet_test.exs
Normal file
60
samples/client/petstore/elixir/test/pet_test.exs
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user