https://github.com/kfsantos/go-api-car
API developed in golang using swagger to create test environment
https://github.com/kfsantos/go-api-car
api-rest gin-contrib gin-gonic go godotenv golang gorm gorm-orm json postgres
Last synced: about 2 months ago
JSON representation
API developed in golang using swagger to create test environment
- Host: GitHub
- URL: https://github.com/kfsantos/go-api-car
- Owner: kfsantos
- Created: 2022-08-09T03:10:07.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-17T23:54:10.000Z (about 1 year ago)
- Last Synced: 2025-02-01T17:44:18.979Z (4 months ago)
- Topics: api-rest, gin-contrib, gin-gonic, go, godotenv, golang, gorm, gorm-orm, json, postgres
- Language: Go
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-api-car
REST API with unit tests and coverage percentage
API developed from a Car CRUD, where unit tests are performed and their percentage of coverage
API developed in golang using swagger to create test environment# Download Gin Framework
go get github.com/gin-gonic/gin
# Download GORM
go get github.com/jinzhu/gorm
# Download Driver Postgres
go get github.com/jinzhu/gorm/dialects/postgres
# Download GoDotEnv
go get github.com/joho/godotenv
# API
localhost:5000/
-
GET
: GET all cars -
POST
: POST create a new car
localhost:5000/:id
-
GET
: GET a car -
PUT
: PUT update a car -
DELETE
: DELETE a car
POST Params
{
"name": "Sentra", "brand": "Nissan", "year": "2022/12/12"
}
PUT Params
{
"ID": 1, "name": "Skyline", "brand": "Nissan"
}
# Test
To create test files
gotests -all -w .
Create Tests
go test -v ./...
Create coverage
-
go test -coverprofile name
-
go tool cover -html=nameCoverProfile