Skip to content

Commit 66ada0f

Browse files
committed
fix: resolve lint issues, pin Docker image, and improve docs
Signed-off-by: Syedowais312 <[email protected]>
1 parent ead6147 commit 66ada0f

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

fasthttp-postgres/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM golang:1.22-alpine AS builder
22

33
WORKDIR /app
44

5-
#install git (needed for go modules somethimes)
5+
# install git (needed for go modules sometimes)
66
RUN apk add --no-cache git
77

88
#copy gomod files first (better caching)
@@ -16,7 +16,7 @@ COPY . .
1616
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app
1717

1818
# ---------- Runtime stage ----------
19-
FROM alpine:latest
19+
FROM alpine:3.19
2020

2121
WORKDIR /app
2222

fasthttp-postgres/README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,37 @@ git clone https://github.com/keploy/samples-go && cd fasthttp-postgres
1313
```bash
1414
curl --silent -O -L https://keploy.io/install.sh && source install.sh
1515
```
16+
## Run the application without Docker
17+
18+
### Prerequisites
19+
- Go 1.22+
20+
- PostgreSQL running locally
21+
22+
### Setup Database
23+
Create a database and apply migrations:
24+
```bash
25+
createdb db
26+
psql db < migrations/init.sql
27+
```
28+
### Set environment variables
29+
```bash
30+
export DB_HOST=localhost
31+
export DB_PORT=5432
32+
export DB_USER=postgres
33+
export DB_PASSWORD=password
34+
export DB_NAME=db
35+
36+
```
37+
### Run the server
38+
```bash
39+
go run main.go
40+
```
41+
The server will start at:
42+
```md
43+
```bash
44+
http://localhost:8080
45+
```
46+
1647

1748
Keploy can be used on Linux, Windows and MacOS through [Docker](https://docs.docker.com/engine/install/).
1849

@@ -30,7 +61,7 @@ Using the docker-compose file we will start :-
3061
keploy record -c "docker-compose up" --container-name=fasthttp_app
3162
```
3263

33-
To genereate testcases we just need to make some API calls. You can use [Postman](https://www.postman.com/), [Hoppscotch](https://hoppscotch.io/), or simply `curl`: -
64+
To generate testcases we just need to make some API calls. You can use [Postman](https://www.postman.com/), [Hoppscotch](https://hoppscotch.io/), or simply `curl`: -
3465

3566
1. Post Requests
3667
```shell
@@ -51,11 +82,12 @@ curl -i http://localhost:8080/books
5182
Now that we have our testcase captured, run the test file.
5283

5384
```shell
54-
keploy test -c "docker-compose up" --container-name=fasthttp_app --goCoverage --delay 10
85+
keploy test -c "docker-compose up" --container-name=fasthttp_app --delay 10
5586
```
5687

5788
![alt text](./img/testrun.png)
5889

59-
_Voila! Our testcases have passed🥳_ . We can also notice that by capturing just few API calls we got around 88.5% of aggregated coverage with keploy generated testcases
90+
_Voila! Our testcases have passed🥳_ . We can also notice that by capturing just a few API calls we achieved high test coverage with Keploy generated testcases
91+
6092

6193
If you like the sample application, Don't forget to star us ✨

fasthttp-postgres/internal/app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/fasthttp/router"
16+
// Blank import required to register the PostgreSQL driver
1617
_ "github.com/lib/pq"
1718
"github.com/valyala/fasthttp"
1819
)

0 commit comments

Comments
 (0)