Skip to content

Commit 33048f6

Browse files
committed
Fix manual tests on client/petstore/c
1 parent 3a9d28d commit 33048f6

7 files changed

Lines changed: 55 additions & 28 deletions

File tree

modules/openapi-generator/src/main/resources/C-libcurl/README.md.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ You'll need the `curl 7.58.0` package in order to build the API. To have code fo
2222
## Install the `curl 7.58.0` package with the following command on Linux.
2323
```bash
2424
sudo apt remove curl
25-
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
26-
tar -xvf curl-7.58.0.tar.gz
27-
cd curl-7.58.0/
25+
wget http://curl.haxx.se/download/curl-7.61.1.tar.gz
26+
tar -xvf curl-7.61.1.tar.gz
27+
cd curl-7.61.1/
2828
./configure
2929
make
3030
sudo make install

samples/client/petstore/c/build-and-test.bash

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# project
6+
mkdir -p build
7+
cd build
8+
59
#install latest curl
610
wget https://curl.haxx.se/download/curl-7.61.1.zip
711
unzip curl-7.61.1.zip
@@ -11,10 +15,9 @@ make
1115
sudo make install
1216
cd ..
1317

14-
# project
15-
cmake .
16-
17-
make
18+
# build project
19+
cmake ..
20+
make
1821

1922
if [ -f unit-manual-PetAPI ]; then ./unit-manual-PetAPI; fi
2023
if [ -f unit-manual-UserAPI ]; then ./unit-manual-UserAPI; fi

samples/client/petstore/c/unit-tests/manual-PetAPI.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ int main() {
5555
list_addElement(tags, exampleTag2);
5656

5757

58-
status_e status = available;
5958
pet_t *pet =
6059
pet_create(EXAMPLE_PET_ID,
6160
category,
6261
petName,
6362
photoUrls,
6463
tags,
65-
status);
64+
openapi_petstore_pet_STATUS_available);
6665

6766
PetAPI_addPet(apiClient, pet);
6867
cJSON *JSONR_local = pet_convertToJSON(pet);
@@ -95,9 +94,9 @@ int main() {
9594
assert(mypet->id == EXAMPLE_PET_ID);
9695
assert(strcmp(mypet->category->name, EXAMPLE_CATEGORY_NAME) == 0);
9796
assert(mypet->category->id == EXAMPLE_CATEGORY_ID);
98-
assert(strcmp(list_getElementAt(mypet->photoUrls,
97+
assert(strcmp(list_getElementAt(mypet->photo_urls,
9998
0)->data, EXAMPLE_URL_1) == 0);
100-
assert(strcmp(list_getElementAt(mypet->photoUrls,
99+
assert(strcmp(list_getElementAt(mypet->photo_urls,
101100
1)->data, EXAMPLE_URL_2) == 0);
102101
assert(((tag_t *) list_getElementAt(mypet->tags,
103102
0)->data)->id == EXAMPLE_TAG_1_ID);

samples/client/petstore/c/unit-tests/manual-StoreAPI.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define PET_ID 12345
1010
#define QUANTITY 50
1111
#define SHIP_DATE "2018-09-24T10:19:09.592Z"
12-
#define STATUS placed
1312
#define COMPLETE true
1413

1514
/*
@@ -27,7 +26,7 @@ int main() {
2726
PET_ID,
2827
QUANTITY,
2928
shipdate,
30-
STATUS,
29+
openapi_petstore_order_STATUS_placed,
3130
COMPLETE);
3231

3332
order_t *returnorder = StoreAPI_placeOrder(apiClient, neworder);

samples/client/petstore/c/unit-tests/manual-UserAPI.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ int main() {
3333
strcpy(phone, PHONE);
3434

3535
user_t *newuser = user_create(USER_ID,
36-
username,
37-
firstname,
38-
lastname,
39-
email,
40-
password,
41-
phone,
42-
USER_STATUS);
36+
username,
37+
firstname,
38+
lastname,
39+
email,
40+
password,
41+
phone,
42+
USER_STATUS,
43+
NULL,
44+
openapi_petstore_preference__cats);
4345

4446
UserAPI_createUser(apiClient, newuser);
4547
user_free(newuser);
@@ -82,7 +84,9 @@ int main() {
8284
email,
8385
password,
8486
phone,
85-
USER_STATUS);
87+
USER_STATUS,
88+
NULL,
89+
openapi_petstore_preference__cats);
8690

8791
UserAPI_updateUser(apiClient2, username1, newuser1);
8892
user_free(newuser1);

samples/client/petstore/c/unit-tests/manual-order.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
#define COMPLETE 1
1313

1414
int main() {
15-
status_e STATUS = placed;
15+
char *shipDate = malloc(strlen(SHIP_DATE) + 1);
16+
strcpy(shipDate, SHIP_DATE);
1617

17-
order_t *neworder = order_create(ORDER_ID, PET_ID, QUANTITY, SHIP_DATE,
18-
STATUS,
19-
COMPLETE);
18+
order_t *neworder = order_create(ORDER_ID, PET_ID, QUANTITY, shipDate,
19+
openapi_petstore_order_STATUS_placed,
20+
COMPLETE);
2021

2122
cJSON *JSONNODE = order_convertToJSON(neworder);
2223

samples/client/petstore/c/unit-tests/manual-user.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,30 @@
1414
#define USER_STATUS 4
1515

1616
int main() {
17-
user_t *newuser = user_create(USER_ID, USER_NAME, FIRST_NAME, LAST_NAME,
18-
EMAIL,
19-
PASSWORD, PHONE, USER_STATUS);
17+
18+
char *username = malloc(strlen(USER_NAME) + 1);
19+
strcpy(username, USER_NAME);
20+
char *firstname = malloc(strlen(FIRST_NAME) + 1);
21+
strcpy(firstname, FIRST_NAME);
22+
char *lastname = malloc(strlen(LAST_NAME) + 1);
23+
strcpy(lastname, LAST_NAME);
24+
char *email = malloc(strlen(EMAIL) + 1);
25+
strcpy(email, EMAIL);
26+
char *password = malloc(strlen(PASSWORD) + 1);
27+
strcpy(password, PASSWORD);
28+
char *phone = malloc(strlen(PHONE) + 1);
29+
strcpy(phone, PHONE);
30+
31+
user_t *newuser = user_create(USER_ID,
32+
username,
33+
firstname,
34+
lastname,
35+
email,
36+
password,
37+
phone,
38+
USER_STATUS,
39+
NULL,
40+
openapi_petstore_preference__cats);
2041

2142
cJSON *JSONNODE = user_convertToJSON(newuser);
2243

0 commit comments

Comments
 (0)