Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.2 Release #107

Merged
merged 85 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
48a5bf2
Create Repo and API Mock in User Package
mhmmdriz Jun 17, 2024
3016bd2
Update Get User by ID
mhmmdriz Jun 17, 2024
92aa6d8
Merge pull request #71 from Capstone-Project-Alterra-Kelompok-8/featu…
mhmmdriz Jun 17, 2024
02075ed
Merge branch 'development' of https://github.com/Capstone-Project-Alt…
mhmmdriz Jun 17, 2024
7a0fe06
Update Feature Update User Profile
mhmmdriz Jun 17, 2024
1e6f274
Merge pull request #73 from Capstone-Project-Alterra-Kelompok-8/featu…
mhmmdriz Jun 17, 2024
a0f7e8e
Merge branch 'development' of https://github.com/Capstone-Project-Alt…
mhmmdriz Jun 17, 2024
16befa4
Update Change Password
mhmmdriz Jun 17, 2024
8a890fa
Merge pull request #74 from Capstone-Project-Alterra-Kelompok-8/featu…
mhmmdriz Jun 17, 2024
688a193
Merge branch 'development' of https://github.com/Capstone-Project-Alt…
mhmmdriz Jun 17, 2024
a461bf1
Add Unit Test on User Package
mhmmdriz Jun 17, 2024
60ff4bb
Merge pull request #75 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 17, 2024
636ce8e
Add Unit Test for Admin Package
mhmmdriz Jun 18, 2024
cd3beec
Merge pull request #77 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 18, 2024
50bc1de
Update Unit Testing and Response on User Package
mhmmdriz Jun 18, 2024
24cee8c
Merge pull request #78 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 18, 2024
32bafb5
add unit test and update usecase
Mifthahuddinnn Jun 18, 2024
518c6dd
Merge pull request #79 from Capstone-Project-Alterra-Kelompok-8/unit-…
Mifthahuddinnn Jun 19, 2024
97d3528
Update README.md
Mifthahuddinnn Jun 19, 2024
53cbd60
Merge pull request #81 from Capstone-Project-Alterra-Kelompok-8/Mifth…
Mifthahuddinnn Jun 19, 2024
678b0b6
update response get comment
Mifthahuddinnn Jun 19, 2024
7d43953
Merge pull request #82 from Capstone-Project-Alterra-Kelompok-8/featu…
Mifthahuddinnn Jun 19, 2024
a913861
update news comment response
Mifthahuddinnn Jun 19, 2024
c3009c9
Merge pull request #83 from Capstone-Project-Alterra-Kelompok-8/featu…
Mifthahuddinnn Jun 19, 2024
9e43f13
Update HLA
Mifthahuddinnn Jun 19, 2024
df54268
Update README.md
Mifthahuddinnn Jun 19, 2024
66e05a3
Update README.md
Mifthahuddinnn Jun 19, 2024
8dc79dc
Add Unit Testing and Minor Update on Complaint Package
mhmmdriz Jun 20, 2024
a1340a9
Merge branch 'development' into unit-test/complaint
mhmmdriz Jun 20, 2024
8c0c725
Merge pull request #84 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 20, 2024
805679a
Update Models/Entities
mhmmdriz Jun 20, 2024
52a1e3a
add unit-test coverage 98.7%
Mifthahuddinnn Jun 20, 2024
92126a8
Merge branch 'development' into unit-test/complaint-process-management
Mifthahuddinnn Jun 20, 2024
0dc73b1
Review
Mifthahuddinnn Jun 20, 2024
8cc59f8
Update README.md
Mifthahuddinnn Jun 20, 2024
156103c
Update Database Table Model and Seeder
mhmmdriz Jun 20, 2024
1b42595
Merge branch 'development' into update/database
mhmmdriz Jun 20, 2024
fe94554
Merge pull request #86 from Capstone-Project-Alterra-Kelompok-8/updat…
mhmmdriz Jun 20, 2024
f0fb012
Update Password Validation and Unit Testing
mhmmdriz Jun 20, 2024
38e6a29
Update main.go
mhmmdriz Jun 20, 2024
dd8a084
Merge pull request #87 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 20, 2024
73bb33c
Update Password Validation and Unit Testing Admin Package
mhmmdriz Jun 20, 2024
2bcaa44
Merge pull request #88 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 20, 2024
e5ac791
Update User and Admin Seeder
mhmmdriz Jun 20, 2024
77e28f2
add complaint-feedback unit-test
Mifthahuddinnn Jun 20, 2024
3c4f5cb
Merge branch 'development' into unit-test/complaint-feedback
Mifthahuddinnn Jun 20, 2024
3bf2a00
Merge pull request #89 from Capstone-Project-Alterra-Kelompok-8/unit-…
Mifthahuddinnn Jun 20, 2024
bcf1b48
Merge pull request #90 from Capstone-Project-Alterra-Kelompok-8/updat…
mhmmdriz Jun 20, 2024
0380181
Add Unit Testing for Regency Package
mhmmdriz Jun 20, 2024
f9cd1ed
Merge pull request #91 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 20, 2024
8965338
add news-feedback unit-test
Mifthahuddinnn Jun 20, 2024
60aeb0c
Merge branch 'development' into unit-test/news-feedback
Mifthahuddinnn Jun 20, 2024
2c3da3a
Merge pull request #92 from Capstone-Project-Alterra-Kelompok-8/unit-…
Mifthahuddinnn Jun 20, 2024
199e45f
add news unit-test
Mifthahuddinnn Jun 21, 2024
5f85c8a
Merge pull request #93 from Capstone-Project-Alterra-Kelompok-8/unit-…
Mifthahuddinnn Jun 21, 2024
7cbe682
update date response
Mifthahuddinnn Jun 22, 2024
ea9ced8
Merge pull request #94 from Capstone-Project-Alterra-Kelompok-8/dashb…
Mifthahuddinnn Jun 22, 2024
0a82358
update response date
Mifthahuddinnn Jun 22, 2024
dd9ae25
Merge pull request #95 from Capstone-Project-Alterra-Kelompok-8/dashb…
Mifthahuddinnn Jun 22, 2024
210630d
add unit-test chatbots
Mifthahuddinnn Jun 22, 2024
e5a5813
Merge pull request #96 from Capstone-Project-Alterra-Kelompok-8/unit-…
Mifthahuddinnn Jun 22, 2024
0e79ed0
add unit-test dashboard
Mifthahuddinnn Jun 22, 2024
4351348
Merge pull request #97 from Capstone-Project-Alterra-Kelompok-8/unit-…
Mifthahuddinnn Jun 22, 2024
99f1fef
fix error in main.go
Mifthahuddinnn Jun 22, 2024
cd0ec8e
Merge pull request #98 from Capstone-Project-Alterra-Kelompok-8/unit-…
Mifthahuddinnn Jun 22, 2024
7eb9856
Add Unit Testing on Complaint Activity Package
mhmmdriz Jun 23, 2024
355cbbe
Merge pull request #99 from Capstone-Project-Alterra-Kelompok-8/unit-…
mhmmdriz Jun 23, 2024
a85ddb1
Add Unit Testing on Complaint File Package
mhmmdriz Jun 23, 2024
1ca277e
Merge branch 'development' into unit-test/complaint-file
mhmmdriz Jun 23, 2024
e75365c
Merge pull request #100 from Capstone-Project-Alterra-Kelompok-8/unit…
mhmmdriz Jun 23, 2024
c032d4c
add news file unit test
Mifthahuddinnn Jun 23, 2024
24aedf9
Merge pull request #101 from Capstone-Project-Alterra-Kelompok-8/unit…
Mifthahuddinnn Jun 23, 2024
b6d5d42
ad complaint like unit-test
Mifthahuddinnn Jun 23, 2024
eedc134
Merge pull request #102 from Capstone-Project-Alterra-Kelompok-8/unit…
Mifthahuddinnn Jun 23, 2024
4379abd
Update Delete Category
mhmmdriz Jun 23, 2024
cdb6d66
Merge pull request #103 from Capstone-Project-Alterra-Kelompok-8/feat…
mhmmdriz Jun 23, 2024
0b373f0
Update Delete Category
mhmmdriz Jun 23, 2024
044a08e
Merge pull request #104 from Capstone-Project-Alterra-Kelompok-8/feat…
mhmmdriz Jun 23, 2024
de81465
Update Delete Category
mhmmdriz Jun 23, 2024
de04864
Merge pull request #105 from Capstone-Project-Alterra-Kelompok-8/feat…
mhmmdriz Jun 23, 2024
79b4c93
Update README.md
mhmmdriz Jun 23, 2024
af06c7c
update response code get by id and get all categories
Mifthahuddinnn Jun 23, 2024
65c3b05
update response code get by id and get all categories
Mifthahuddinnn Jun 23, 2024
a370fa8
Merge pull request #106 from Capstone-Project-Alterra-Kelompok-8/feat…
Mifthahuddinnn Jun 23, 2024
7694329
Add Coverage Check using Github Actions
mhmmdriz Jun 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/coverage_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Test and Coverage Check

on:
push:
branches:
- main
- development

jobs:
test-and-check-coverage:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.21.7'

- name: Install dependencies and update go.mod/go.sum
run: |
go get -t -v ./...
go mod tidy

- name: Run tests
run: |
go test -cover ./usecases/admin/...
go test -cover ./usecases/category/...
go test -cover ./usecases/chatbot/...
go test -cover ./usecases/complaint/...
go test -cover ./usecases/complaint_activity/...
go test -cover ./usecases/complaint_file/...
go test -cover ./usecases/complaint_like/...
go test -cover ./usecases/complaint_process/...
go test -cover ./usecases/dashboard/...
go test -cover ./usecases/discussion/...
go test -cover ./usecases/news/...
go test -cover ./usecases/news_comment/...
go test -cover ./usecases/news_file/...
go test -cover ./usecases/news_like/...
go test -cover ./usecases/regency/...
go test -cover ./usecases/user/...

- name: Check coverage
run: |
admin_coverage=$(go test -cover ./usecases/admin/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
category_coverage=$(go test -cover ./usecases/category/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
chatbot_coverage=$(go test -cover ./usecases/chatbot/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
complaint_coverage=$(go test -cover ./usecases/complaint/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
complaint_activity_coverage=$(go test -cover ./usecases/complaint_activity/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
complaint_file_coverage=$(go test -cover ./usecases/complaint_file/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
complaint_like_coverage=$(go test -cover ./usecases/complaint_like/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
complaint_process_coverage=$(go test -cover ./usecases/complaint_process/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
dashboard_coverage=$(go test -cover ./usecases/dashboard/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
discussion_coverage=$(go test -cover ./usecases/discussion/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
news_coverage=$(go test -cover ./usecases/news/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
news_comment_coverage=$(go test -cover ./usecases/news_comment/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
news_file_coverage=$(go test -cover ./usecases/news_file/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
news_like_coverage=$(go test -cover ./usecases/news_like/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
regency_coverage=$(go test -cover ./usecases/regency/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')
user_coverage=$(go test -cover ./usecases/user/... | grep -o '[0-9.]\+%' | cut -d'.' -f1 | tr -d '%')

if [ $admin_coverage -ge 90 ] && [ $category_coverage -ge 90 ] && [ $chatbot_coverage -ge 90 ] && [ $complaint_coverage -ge 90 ] && [ $complaint_activity_coverage -ge 90 ] && [ $complaint_file_coverage -ge 90 ] && [ $complaint_like_coverage -ge 90 ] && [ $complaint_process_coverage -ge 90 ] && [ $dashboard_coverage -ge 90 ] && [ $discussion_coverage -ge 90 ] && [ $news_coverage -ge 90 ] && [ $news_comment_coverage -ge 90 ] && [ $news_file_coverage -ge 90 ] && [ $news_like_coverage -ge 90 ] && [ $regency_coverage -ge 90 ] && [ $user_coverage -ge 90 ]; then
echo "All services have coverage above 90%"
else
echo "Some services have coverage below 90%"
exit 1
fi
Binary file modified README.md
Binary file not shown.
6 changes: 6 additions & 0 deletions constants/errror.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ var (
ErrInvalidFileFormat = errors.New("invalid file format")
ErrForgotPasswordOTPNotVerified = errors.New("forgot password otp not verified")
ErrConfirmPasswordDoesntMatch = errors.New("confirm password doesn't match")
ErrColumnsDoesntMatch = errors.New("columns doesn't match")
ErrInvalidCategoryIDFormat = errors.New("invalid category id format")
ErrEmailNotRegistered = errors.New("email not registered")
ErrDiscussionNotFound = errors.New("discussion not found")
ErrPasswordMustBeAtLeast8Characters = errors.New("password must be at least 8 characters")
ErrCategoryHasBeenUsed = errors.New("category has been used")
)
15 changes: 9 additions & 6 deletions controllers/category/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ func (cc *CategoryController) GetAll(c echo.Context) error {
return c.JSON(utils.ConvertResponseCode(err), base.NewErrorResponse(err.Error()))
}

return c.JSON(http.StatusOK, base.NewSuccessResponse("Success get all categories", categories))
responseCategories := make([]*response.Get, len(categories))
for i, category := range categories {
responseCategories[i] = response.GetFromEntitiesToResponse(&category)
}

return c.JSON(http.StatusOK, base.NewSuccessResponse("Success get all categories", responseCategories))
}

func (cc *CategoryController) GetByID(c echo.Context) error {
Expand All @@ -42,10 +47,6 @@ func (cc *CategoryController) GetByID(c echo.Context) error {
return c.JSON(http.StatusInternalServerError, base.NewErrorResponse(err.Error()))
}

if err != nil {
return c.JSON(http.StatusBadRequest, base.NewErrorResponse(err.Error()))
}

category, err := cc.useCase.GetByID(id)
if err != nil {
if errors.Is(err, constants.ErrCategoryNotFound) {
Expand All @@ -54,7 +55,9 @@ func (cc *CategoryController) GetByID(c echo.Context) error {
return c.JSON(utils.ConvertResponseCode(err), base.NewErrorResponse(err.Error()))
}

return c.JSON(http.StatusOK, base.NewSuccessResponse("Success get category by ID", category))
responseCategory := response.GetFromEntitiesToResponse(&category)

return c.JSON(http.StatusOK, base.NewSuccessResponse("Success get category by ID", responseCategory))
}

func (cc *CategoryController) CreateCategory(c echo.Context) error {
Expand Down
3 changes: 1 addition & 2 deletions controllers/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"e-complaint-api/usecases/dashboard"
"github.com/labstack/echo/v4"
"net/http"
"time"
)

type DashboardController struct {
Expand All @@ -31,7 +30,7 @@ func (ctrl *DashboardController) GetDashboardData(c echo.Context) error {
Name: complaint.User.Name,
},
Complaint: response.Complaint{
Date: complaint.Date.Format(time.RFC3339),
Date: complaint.CreatedAt.Format("2 January 2006 15:04:05"),
Status: complaint.Status,
},
Category: response.Category{
Expand Down
7 changes: 1 addition & 6 deletions controllers/user/request/update_password.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package request

type UpdatePassword struct {
NewPassword string `json:"new_password" form:"new_password"`
ConfirmNewPassword string `json:"confirm_new_password" form:"confirm_new_password"`
}

func (up *UpdatePassword) ToEntities() (string, string) {
return up.ConfirmNewPassword, up.NewPassword
NewPassword string `json:"new_password" form:"new_password"`
}
25 changes: 3 additions & 22 deletions controllers/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,9 @@ func (uc *UserController) GetUserByID(c echo.Context) error {
return c.JSON(http.StatusBadRequest, base.NewErrorResponse(constants.ErrInvalidIDFormat.Error()))
}

jwtID, err := utils.GetIDFromJWT(c)
if err != nil {
return c.JSON(http.StatusInternalServerError, base.NewErrorResponse(err.Error()))
}

if id != jwtID {
return c.JSON(http.StatusUnauthorized, base.NewErrorResponse(constants.ErrUnauthorized.Error()))
}

user, err := uc.userUseCase.GetUserByID(id)
if err != nil {
return c.JSON(http.StatusInternalServerError, base.NewErrorResponse(err.Error()))
return c.JSON(utils.ConvertResponseCode(err), base.NewErrorResponse(err.Error()))
}

userResponse := response.GetUsersFromEntitiesToResponse(user)
Expand Down Expand Up @@ -159,7 +150,7 @@ func (uc *UserController) DeleteUser(c echo.Context) error {

err = uc.userUseCase.Delete(id)
if err != nil {
return c.JSON(http.StatusInternalServerError, base.NewErrorResponse(err.Error()))
return c.JSON(utils.ConvertResponseCode(err), base.NewErrorResponse(err.Error()))
}

return c.JSON(http.StatusOK, base.NewSuccessResponse("Success Delete User", nil))
Expand All @@ -171,22 +162,12 @@ func (uc *UserController) UpdatePassword(c echo.Context) error {
return c.JSON(http.StatusInternalServerError, base.NewErrorResponse(err.Error()))
}

userRole, err := utils.GetRoleFromJWT(c)
if err != nil {
return c.JSON(http.StatusInternalServerError, base.NewErrorResponse(err.Error()))
}

if userRole != "user" {
return c.JSON(http.StatusUnauthorized, base.NewErrorResponse(constants.ErrUnauthorized.Error()))
}

var passwordRequest request.UpdatePassword
if err := c.Bind(&passwordRequest); err != nil {
return c.JSON(http.StatusBadRequest, base.NewErrorResponse(err.Error()))
}

newPassword, confirmPassword := passwordRequest.ToEntities()
err = uc.userUseCase.UpdatePassword(jwtID, newPassword, confirmPassword)
err = uc.userUseCase.UpdatePassword(jwtID, passwordRequest.NewPassword)
if err != nil {
return c.JSON(http.StatusBadRequest, base.NewErrorResponse(err.Error()))
}
Expand Down
Loading
Loading