@@ -5,19 +5,18 @@ import (
55 "testing"
66
77 "github.com/gavv/httpexpect/v2"
8+ modelsTest "github.com/ockibagusp/golang-website-example/tests/models"
89)
910
1011func TestAdminDeletePermanently (t * testing.T ) {
1112 no_auth := setupTestServer (t )
12- auth_admin := setupTestServerAuth (no_auth , 1 )
13- // auth_sugriwa := setupTestServerAuth(no_auth, 2)
1413
1514 // test for db users
1615 truncateUsers (db )
1716
1817 test_cases := []struct {
1918 name string
20- expect * httpexpect. Expect // auth or no-auth
19+ expect string // auth or no-auth
2120 url_query string
2221 status int
2322 }{
@@ -26,7 +25,7 @@ func TestAdminDeletePermanently(t *testing.T) {
2625 */
2726 {
2827 name : "delete permanently [admin] to GET it success: all" ,
29- expect : auth_admin ,
28+ expect : ADMIN ,
3029 // HTTP response status: 200 OK
3130 status : http .StatusOK ,
3231 },
@@ -61,18 +60,18 @@ func TestAdminDeletePermanently(t *testing.T) {
6160
6261 var expect = test.expect
6362 */
64- var expect * httpexpect. Expect = test .expect
63+ modelsTest . UserSelectTest = test .expect // ADMIN and SUGRIWA
6564
6665 t .Run (test .name , func (t * testing.T ) {
6766 // @route: exemple "/admin/delete-permanently?admin=all"
6867 if test .url_query != "" {
69- result = expect .GET ("/admin/delete-permanently" ).
68+ result = no_auth .GET ("/admin/delete-permanently" ).
7069 WithQuery (test .url_query , "all" ).
7170 Expect ().
7271 Status (test .status )
7372 } else {
7473 // @route: "/admin/delete-permanently"
75- result = expect .GET ("/admin/delete-permanently" ).
74+ result = no_auth .GET ("/admin/delete-permanently" ).
7675 Expect ().
7776 Status (test .status )
7877 }
0 commit comments