Survey application that have some questions that can be answered
ensuring all dependencies with go mod download
build application with script go build main.go
run application ./main
run app with auto build go run main.go
execute this command to run app with docker
docker-compose up --build
note that you have to ensure DB_HOST in .env
are the same with host in docker-compose.yml
shutdown docker with docker-compose down --remove-orphans --volumes
execute this command to run test with docker
docker-compose -f docker-compose.test.yml up --build --abort-on-container-exit
note that if you want to run test with docker, ensure that DB_HOST using the same host in docker-compose.test.yml
and .env
in package tests
execute this command to run test with go test framework
go test github.com/mariotj/survey-app/tests
List of all API in survey app:
-
Create Survey
POST /api/v1/survey
request body
{"name" : "desired survey name"}
-
Update Survey
PUT /api/v1/survey
request body
{"id": id, "name" : "desired survey name"}
-
Delete Survey by id
DELETE /api/v1/survey/:id
-
Get survey by id
GET /api/v1/survey/:id
-
Get all survey
GET /api/v1/survey
-
Add question by survey id
POST /api/v1/question
request body
{"question" : "desired question", "survey_id": id}
-
Update Question by question id
PUT /api/v1/question
request body
{"id": id, "question" : "desired update question"}
-
Get all question by survey id
GET /api/v1/question/survey/:id
-
Delete question by question id
DELETE /api/v1/question/question/:id
-
Delete all question by survey id
DELETE /api/v1/question/survey/:id
-
Add answer to a question
POST /api/v1/survey/answer
request body
{"answer" : "desired answer", "username": "username", "survey_question_id": id}
-
Update answer by id
PUT /api/v1/survey/answer
request body
{"answer" : "desired answer", "id": id}
-
Get report for survey by survey id (including question and answer)
GET /api/v1/report/survey/:id