-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
61 lines (50 loc) · 1.75 KB
/
Copy pathmain_test.go
File metadata and controls
61 lines (50 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main_test
import (
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http/httptest"
"split-the-bill-server/domain/service/impl"
"split-the-bill-server/domain/util"
"split-the-bill-server/presentation/handler"
"split-the-bill-server/presentation/middleware"
"split-the-bill-server/presentation/router"
"split-the-bill-server/storage/ephemeral"
"split-the-bill-server/storage/ephemeral/eph_storages"
"testing"
)
// TestBuild tests whether the fiber client starts correctly.
func TestBuild(t *testing.T) {
// Test Server Configuration
app := fiber.New()
e, err := ephemeral.NewEphemeral()
require.NoError(t, err)
v, err := util.NewPasswordValidator()
require.NoError(t, err)
//storages
userStorage := eph_storages.NewUserStorage(e)
groupStorage := eph_storages.NewGroupStorage(e)
cookieStorage := eph_storages.NewCookieStorage(e)
billStorage := eph_storages.NewBillStorage(e)
//services
userService := impl.NewUserService(&userStorage, &cookieStorage)
groupService := impl.NewGroupService(&groupStorage)
billService := impl.NewBillService(&billStorage, &groupStorage)
//handlers
userHandler := handler.NewUserHandler(&userService, v)
groupHandler := handler.NewGroupHandler(&groupService)
billHandler := handler.NewBillHandler(&billService, &groupService)
// authenticator
authenticator := middleware.NewAuthenticator(&cookieStorage)
//routing
router.SetupRoutes(app, *userHandler, *groupHandler, *billHandler, *authenticator)
// Create a new http get request on landingpage
req := httptest.NewRequest("GET", "/", nil)
// Perform request
resp, _ := app.Test(req, 100)
// Testing logs
t.Log(resp.StatusCode)
t.Log(resp)
// Expect HTTP.OK
assert.Equal(t, 200, resp.StatusCode)
}