@@ -6,40 +6,39 @@ import (
66 "testing"
77
88 "github.com/gavv/httpexpect/v2"
9+ modelsTest "github.com/ockibagusp/golang-website-example/tests/models"
910 "github.com/stretchr/testify/assert"
1011)
1112
1213func TestAboutSuccess (t * testing.T ) {
1314 assert := assert .New (t )
1415
1516 no_auth := setupTestServer (t )
16- auth_admin := setupTestServerAuth (no_auth , 1 )
17- auth_sugriwa := setupTestServerAuth (no_auth , 2 )
1817
1918 test_cases := []struct {
2019 name string
21- expect * httpexpect. Expect // auth_admin, session_sugriwa or no-auth
20+ expect string // admin, sugriwa
2221 html_navbar regex
2322 }{
2423 {
2524 name : "about [no-auth] success" ,
26- expect : no_auth ,
25+ expect : "" ,
2726 html_navbar : regex {
2827 must_compile : `<a href="/login" class="btn btn-outline-success my-2 my-sm-0">(.*)</a>` ,
2928 actual : `<a href="/login" class="btn btn-outline-success my-2 my-sm-0">Login</a>` ,
3029 },
3130 },
3231 {
3332 name : "about [admin] success" ,
34- expect : auth_admin ,
33+ expect : ADMIN ,
3534 html_navbar : regex {
3635 must_compile : `<a class="btn">(.*)</a>` ,
3736 actual : `<a class="btn">ADMIN</a>` ,
3837 },
3938 },
4039 {
4140 name : "home [user] success" ,
42- expect : auth_sugriwa ,
41+ expect : SUGRIWA ,
4342 html_navbar : regex {
4443 must_compile : `<a href="/users" class="btn btn-outline-secondary my-2 my-sm-0">(.*)</a>` ,
4544 actual : `<a href="/users" class="btn btn-outline-secondary my-2 my-sm-0">Users</a>` ,
@@ -49,10 +48,10 @@ func TestAboutSuccess(t *testing.T) {
4948
5049 for _ , test := range test_cases {
5150 var result * httpexpect.Response
52- expect : = test .expect // auth_admin, auth_sugriwa or no-auth
51+ modelsTest . UserSelectTest = test .expect // auth_admin, auth_sugriwa or no-auth
5352
5453 t .Run (test .name , func (t * testing.T ) {
55- result = expect .GET ("/about" ).
54+ result = no_auth .GET ("/about" ).
5655 Expect ().
5756 Status (http .StatusOK )
5857
0 commit comments