Skip to content

API developed in golang using swagger to create test environment

Notifications You must be signed in to change notification settings

kfsantos/go-api-car

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

    create cover profiler

  • go test -coverprofile name
  • open cover profiler

  • go tool cover -html=nameCoverProfile

Releases

No releases published

Packages

No packages published

Languages