generated from keploy/template
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from Sonichigo/main
fix: docker-compose file and readme with buildDelay
- Loading branch information
Showing
22 changed files
with
1,736 additions
and
176 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Use an official Golang runtime as a parent image | ||
FROM golang:1.20-bookworm | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy the local package files to the container's workspace | ||
COPY . . | ||
|
||
# Build the Go application | ||
RUN go build -o main . | ||
|
||
# Expose port 8080 | ||
EXPOSE 3500 | ||
|
||
# Command to run the Go application | ||
CMD ["./main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Server Side events | ||
A sample app to test Keploy integration capabilities with realtime subscriptions such as SSE | ||
|
||
## Installation Setup | ||
|
||
#### Server | ||
```bash | ||
git clone https://github.com/keploy/samples-go.git && cd samples-go/sse-svelte | ||
go mod download | ||
``` | ||
|
||
## Installation Keploy | ||
|
||
Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system archieture, install the keploy latest binary release | ||
|
||
**1. AMD Architecture** | ||
|
||
```shell | ||
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp | ||
|
||
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy | ||
``` | ||
|
||
<details> | ||
<summary> 2. ARM Architecture </summary> | ||
|
||
```shell | ||
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_arm64.tar.gz" | tar xz -C /tmp | ||
|
||
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy | ||
``` | ||
|
||
</details> | ||
|
||
### Start MongoDB Instance | ||
Using the docker-compose file we will start our mongodb instance:- | ||
|
||
```bash | ||
# Start Postgres | ||
docker-compose up mongo | ||
``` | ||
|
||
### Build Application Binary | ||
Now, we will create the binary of our application:- | ||
|
||
```bash | ||
go build -o application . | ||
``` | ||
Once we have our applicaiton binary ready, we will start the application with keploy to start capturing the testcases. | ||
|
||
## Capture the test cases | ||
```bash | ||
sudo -E keploy record "./application" | ||
``` | ||
|
||
### Start the UI | ||
We will capture our test from the UI written in Svelte.js | ||
```bash | ||
cd svelte-app && npm install && npm run dev | ||
``` | ||
|
||
## Run the Testcases | ||
Now let's run the test mode :- | ||
|
||
```shell | ||
sudo -E keploy test -c "./keploy-gql" --delay 10 | ||
``` | ||
|
||
output should look like | ||
|
||
![Testrun](./img/testrun.png?raw=true) | ||
|
||
So no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to MongoDb 😄** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: "3.9" | ||
services: | ||
go-app: | ||
build: | ||
context: . | ||
container_name: sseMongoApp | ||
ports: | ||
- "3500:3500" | ||
depends_on: | ||
- mongo | ||
|
||
mongo: | ||
image: "mongo" | ||
container_name: mongoDB | ||
ports: | ||
- "27017:27017" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module github.com/sonichigo/sse-mongo | ||
|
||
go 1.20 | ||
|
||
require go.mongodb.org/mongo-driver v1.13.0 | ||
|
||
require ( | ||
github.com/golang/snappy v0.0.1 // indirect | ||
github.com/klauspost/compress v1.13.6 // indirect | ||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect | ||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect | ||
github.com/xdg-go/scram v1.1.2 // indirect | ||
github.com/xdg-go/stringprep v1.0.4 // indirect | ||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect | ||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect | ||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect | ||
golang.org/x/text v0.7.0 // indirect | ||
) |
Oops, something went wrong.