forked from loafle/openapi-generator-original
[Rust][reqwest] add tests to CI (#6454)
* add tests to rust reqwest petstore client * add rust reqwest tests to ci
This commit is contained in:
parent
92a350ed72
commit
105efd3c68
1
pom.xml
1
pom.xml
@ -1206,6 +1206,7 @@
|
||||
<module>samples/client/petstore/c</module>
|
||||
<module>samples/client/petstore/cpp-qt5</module>
|
||||
<module>samples/client/petstore/rust</module>
|
||||
<module>samples/client/petstore/rust/reqwest/petstore</module>
|
||||
<!--<module>samples/client/petstore/perl</module>-->
|
||||
<module>samples/client/petstore/php/OpenAPIClient-php</module>
|
||||
<module>samples/openapi3/client/petstore/php/OpenAPIClient-php</module>
|
||||
|
46
samples/client/petstore/rust/reqwest/petstore/pom.xml
Normal file
46
samples/client/petstore/rust/reqwest/petstore/pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>RustReqwestClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Rust Reqwest 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>bundle-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>cargo</executable>
|
||||
<arguments>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,34 @@
|
||||
extern crate petstore_reqwest;
|
||||
use petstore_reqwest::apis::PetApi;
|
||||
use petstore_reqwest::apis::PetApiClient;
|
||||
use petstore_reqwest::apis::configuration;
|
||||
//use petstore_reqwest::apis::PetApiUpdatePetWithFormParams;
|
||||
use petstore_reqwest::models::{Pet};
|
||||
use std::option::Option;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
fn test_pet() {
|
||||
let config = configuration::Configuration::new();
|
||||
let pet_api_client = PetApiClient::new(Rc::new(config));
|
||||
|
||||
// create pet object
|
||||
let photo_urls = vec!["https://11".to_string(), "https://22".to_string()];
|
||||
let mut new_pet = Pet::new("Rust Pet".to_string(), photo_urls);
|
||||
new_pet.id = Option::Some(8787);
|
||||
|
||||
// add pet
|
||||
let _add_result = pet_api_client.add_pet(new_pet);
|
||||
|
||||
// get pet
|
||||
let pet_result = pet_api_client.get_pet_by_id(8787);
|
||||
|
||||
let _pet_result = match pet_result {
|
||||
Ok(pet) => {
|
||||
assert_eq!(pet.id, Option::Some(8787));
|
||||
assert_eq!(pet.name, "Rust Pet");
|
||||
assert_eq!(pet.photo_urls, vec!["https://11".to_string(), "https://22".to_string()]);
|
||||
},
|
||||
Err(error) => println!("error: {:?}", error),
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user