Skip to content

Commit 3e8d4b7

Browse files
committed
[22/1/23] [14/1/23] testing fix all controller, does not DeleteUser
1 parent 49075e9 commit 3e8d4b7

File tree

6 files changed

+197
-126
lines changed

6 files changed

+197
-126
lines changed

controllers/home_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
func (controller Controller) Home(c echo.Context) error {
2121
// Please note the the second parameter "home.html" is the template name and should
2222
// be equal to one of the keys in the TemplateRegistry array defined in main.go
23+
// ?
2324
session, _ := middleware.GetAuth(c)
2425
log := log.WithFields(log.Fields{
2526
"username": session.Values["username"],

golang-website-example.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,39 @@ time="2023-01-14T15:14:15+07:00" level=info msg="models.User: [+]success" route=
4141
v about controller
4242
- admin controller
4343

44+
--- FAIL: TestUsersController
45+
- user_controller_test.go:253
46+
- user_controller_test.go:263
47+
48+
http://127.0.0.1:35351/users
49+
http://127.0.0.1:35351/users?admin=all
50+
http://127.0.0.1:35351/users?user=all
51+
http://127.0.0.1:35351/users?false=all
52+
53+
--- FAIL: TestCreateUserController
54+
users_[admin]_to_GET_create_it_success
55+
GET http://127.0.0.1:39181/users/add
56+
57+
- user_controller_test.go:518
58+
59+
--- FAIL: TestCreateUserController/user_[admin]_to_POST_create_it_success
60+
61+
POST http://127.0.0.1:39181/users/add
62+
63+
--- FAIL: TestCreateUserController/users_[admin]_to_POST_create_it_failure:_Duplicate_entry
64+
65+
--- FAIL: TestReadUserController
66+
67+
--- FAIL: TestUpdateUserController
68+
--- FAIL: TestUpdateUserController/users_[admin]_to_admin_GET_update_it_success:_id=1
69+
70+
--- FAIL: TestUpdateUserController/users_[admin]_to_user_GET_update_it_success:_id=2
71+
72+
--- FAIL: TestUpdateUserController/users_[admin]_to_admin_POST_update_it_success:_id=1
73+
74+
--- FAIL: TestUpdateUserByPasswordUserController
75+
--- FAIL: TestUpdateUserByPasswordUserController/users_[admin]_to_GET_update_user_by_password_it_success:_id=1
76+
4477
2. [v] controller UpdateUser: validation
4578

4679
3. [v] test controller DeteleUser: id=3

tests/about_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/gavv/httpexpect/v2"
9+
"github.com/ockibagusp/golang-website-example/tests/method"
910
modelsTest "github.com/ockibagusp/golang-website-example/tests/models"
1011
"github.com/stretchr/testify/assert"
1112
)
@@ -15,6 +16,11 @@ func TestAboutSuccess(t *testing.T) {
1516

1617
no_auth := setupTestServer(t)
1718

19+
// test for SetSession = false
20+
method.SetSession = false
21+
// test for db users
22+
truncateUsers(db)
23+
1824
test_cases := []struct {
1925
name string
2026
expect string // admin, sugriwa

tests/admin_controller_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import (
55
"testing"
66

77
"github.com/gavv/httpexpect/v2"
8+
"github.com/ockibagusp/golang-website-example/tests/method"
89
modelsTest "github.com/ockibagusp/golang-website-example/tests/models"
910
)
1011

1112
func TestAdminDeletePermanently(t *testing.T) {
1213
no_auth := setupTestServer(t)
1314

15+
// test for SetSession = false
16+
method.SetSession = false
1417
// test for db users
1518
truncateUsers(db)
1619

tests/home_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/gavv/httpexpect/v2"
9+
"github.com/ockibagusp/golang-website-example/tests/method"
910
modelsTest "github.com/ockibagusp/golang-website-example/tests/models"
1011
"github.com/stretchr/testify/assert"
1112
)
@@ -15,6 +16,11 @@ func TestHomeController(t *testing.T) {
1516

1617
no_auth := setupTestServer(t)
1718

19+
// test for SetSession = false
20+
method.SetSession = false
21+
// test for db users
22+
truncateUsers(db)
23+
1824
test_cases := []struct {
1925
name string
2026
expect string // admin, sugriwa

0 commit comments

Comments
 (0)