Skip to content

Commit 75b6135

Browse files
AbbhiishekSonichigo
authored andcommitted
doc: sample rust mongo rest app (#451)
* doc: sample rust mongo rest app Signed-off-by: Abhishek kushwaha <[email protected]> * docs: sample rust mongo rest app Signed-off-by: Abhishek kushwaha <[email protected]> * chore: error guessing Signed-off-by: Abhishek kushwaha <[email protected]> * chore: logs * Update sample-rust-crud-mongo.md Signed-off-by: Animesh Pathak <[email protected]> --------- Signed-off-by: Abhishek kushwaha <[email protected]> Signed-off-by: Animesh Pathak <[email protected]> Co-authored-by: Animesh Pathak <[email protected]>
1 parent a8f529c commit 75b6135

9 files changed

+117
-3
lines changed
108 KB
Loading
292 KB
Loading
126 KB
Loading
121 KB
Loading
106 KB
Loading
160 KB
Loading
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
id: sample-rust-crud-mongo
3+
title: Rust CRUD REST API with MongoDB
4+
sidebar_label: Rust + MongoDB (REST)
5+
description: A sample CRUD REST API application to test Keploy integration capabilities using Rust and MongoDB.
6+
tags:
7+
- Rust
8+
- MongoDB
9+
- REST API
10+
keyword:
11+
- Rust
12+
- MongoDB
13+
- API Test generator
14+
- Auto Testcase generation
15+
- CRUD
16+
- REST
17+
---
18+
19+
## Introduction
20+
21+
This is a sample CRUD REST API application to showcase Keploy integration capabilities using Rust and MongoDB. Let's get started! 🚀
22+
23+
import InstallationGuide from '../concepts/installation.md'
24+
25+
<InstallationGuide/>
26+
27+
## Get Started! 🎬
28+
29+
### Setup app
30+
31+
Now that we have Keploy installed, let's set up our application.
32+
33+
```bash
34+
git clone https://github.com/keploy/samples-rust
35+
cd samples-rust/CRUD-rust-mongo
36+
```
37+
38+
## Running App Locally on Linux/WSL 🐧
39+
40+
We will be using Docker compose to run Mongo on Docker container.
41+
42+
### Let's start the MongoDB Instance
43+
44+
Open the root directory path in your terminal and then execute the following command:
45+
46+
```bash
47+
docker-compose up -d
48+
```
49+
50+
### Run the app
51+
52+
```bash
53+
cargo r -r
54+
```
55+
56+
The app will be running on port 8000.
57+
58+
#### Capture testcase
59+
60+
On same terminal execute the following command:
61+
62+
```bash
63+
keploy record -c 'cargo r -r'
64+
```
65+
66+
The output will be as follows:
67+
![RecordRun](/img/rust-mongo-rest-test-run.png?raw=true)
68+
69+
### Generate testcase
70+
71+
Open Postman or any other tool, or utilize the Postman VSCode extension. Click on the import icon (shown below):
72+
73+
![TestRun](/img/rust-mongo-postman-collection-import-button.png?raw=true)
74+
75+
Import the file named: `Note App.postman_collection.json`
76+
77+
After that, Postman will display a similar window:
78+
79+
![TestRun](/img/rust-mongo-rest-postman-collection.png?raw=true)
80+
81+
Hit the Create Note Request with the available data and you will get the following output in your terminal:
82+
83+
```bash
84+
🐰 Keploy: 2024-08-27T21:06:57+05:30 t 8INFO
85+
🟠 Keploy has captured test cases for the user's application. {"path": "/root/samples-rust/CRUD-rust-mongo/keploy/test-set-3/tests", "testcase name": "test-1"}
86+
```
87+
88+
![TestRun](/img/rust-mongo-rest-postman-create-success.png?raw=true)
89+
90+
Afterward, create a GET all request, and you will get the following output in your terminal:
91+
92+
```bash
93+
🐰 Keploy: 2024-08-27T21:13:41+05:30 INFO 🟠 Keploy has captured test cases for the user's application. {"path": "/root/samples-rust/CRUD-rust-mongo/keploy/test-set-3/tests", "testcase name": "test-3"}
94+
```
95+
96+
![Test-case](/img/rust-mongo-rest-postman-get-all-success.png?raw=true)
97+
98+
We peformed two requests, one to create a note and one to get all notes. These requests are captured as testcases by Keploy.
99+
100+
### Run the testcases
101+
102+
Now, let's start keploy in test mode to run our test cases :
103+
104+
```bash
105+
keploy test -c 'cargo r -r'
106+
```
107+
108+
We get the following output in the terminal -
109+
110+
![TestRun](/img/rust-mongo-rest-test-run-2.png?raw=true)
111+
_Voila!! Our testcases has passed 🌟_

versioned_docs/version-2.0.0/quickstart/samples-rust.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
---
22
id: samples-rust
33
title: Rust Sample Application
4-
sidebar_label: Rust + Mongo
4+
sidebar_label: Rust + Mongo (GraphQL)
55
description: The following sample app to test Keploy integration capabilities using rust and MongoDb.
66
tags:
77
- Rust
88
- MongoDB
9+
- GraphQL
910
keyword:
1011
- Rust
1112
- MongoDB
13+
- GraphQL
1214
- API Test generator
1315
- Auto Testcase generation
1416
---
@@ -49,7 +51,7 @@ sudo -E env PATH=$PATH keploy record -c 'cargo run'
4951

5052
#### Generate testcase
5153

52-
Go to the http://127.0.0.1:8080 and create some queries.
54+
Go to the http://127.0.0.1:8000 and create some queries.
5355

5456
We will get the following output in our terminal
5557

versioned_sidebars/version-2.0.0-sidebars.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@
120120
"collapsible": true,
121121
"collapsed": true,
122122
"items": [
123-
"quickstart/samples-rust"
123+
"quickstart/samples-rust",
124+
"quickstart/sample-rust-crud-mongo"
124125
]
125126
},
126127
{

0 commit comments

Comments
 (0)