Skip to content

Commit

Permalink
Merge pull request #85 from Sonichigo/main
Browse files Browse the repository at this point in the history
fix: docker-compose file and readme with buildDelay
  • Loading branch information
Sarthak160 authored Dec 14, 2023
2 parents 3ab30bf + 9352b87 commit 3f4fe46
Show file tree
Hide file tree
Showing 22 changed files with 1,736 additions and 176 deletions.
135 changes: 0 additions & 135 deletions gin-mongo/keploy/test-set-0/mocks.yaml

This file was deleted.

37 changes: 0 additions & 37 deletions gin-mongo/keploy/test-set-0/tests/test-1.yaml

This file was deleted.

1 change: 1 addition & 0 deletions graphql-sql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
postgres:
image: postgres:10.5
restart: always
container_name: graphql-sql-postgres-1
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
Expand Down
6 changes: 3 additions & 3 deletions mux-sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ docker build -t mux-app:1.0 .
## Capture the Testcases

```zsh
keploy record -c "docker run -p 8010:8010 --name muxSqlApp --network keploy-network mux-app:1.0"
keploy record -c "docker run -p 8010:8010 --name muxSqlApp --network keploy-network mux-app:1.0" --buildDelay 50s
```

![Testcase](./img/testcase.png?raw=true)
Expand All @@ -154,7 +154,7 @@ curl --request POST \
--header 'content-type: application/json' \
--data '{
"name":"Bubbles",
"price": 123
"price": 124
}'
```
this will return the response.
Expand Down Expand Up @@ -182,7 +182,7 @@ Now both these API calls were captured as editable testcases and written to ``ke
Now that we have our testcase captured, run the test file.

```shell
keploy test -c "sudo docker run -p 8010:8010 --net keploy-network --name muxSqlApp mux-app:1.0" --delay 10
keploy test -c "sudo docker run -p 8010:8010 --net keploy-network --name muxSqlApp mux-app:1.0" --buildDelay 50s
```
So no need to setup dependencies like mongoDB, web-go locally or write mocks for your testing.

Expand Down
13 changes: 12 additions & 1 deletion mux-sql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
version: '3.7'
services:
go-app:
build:
context: .
container_name: muxSqlApp
ports:
- "8010:8010"
depends_on:
- postgres
networks:
- keploy-network

postgres:
image: postgres:10.5
restart: always
container_name: mux-sql-postgres-1
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
Expand Down
17 changes: 17 additions & 0 deletions sse-svelte/Dockerfile
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"]
73 changes: 73 additions & 0 deletions sse-svelte/README.md
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 😄**
16 changes: 16 additions & 0 deletions sse-svelte/docker-compose.yml
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"
18 changes: 18 additions & 0 deletions sse-svelte/go.mod
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
)
Loading

0 comments on commit 3f4fe46

Please sign in to comment.