-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
62 lines (50 loc) · 1.56 KB
/
main_test.go
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
62
package main
import (
"context"
"testing"
app "github.com/ncpleslie/wmata-train-tracker/app"
"github.com/stretchr/testify/mock"
)
type MockQueries struct {
mock.Mock
}
func (m *MockQueries) SetDefaultStationId(ctx context.Context, stationID string) error {
args := m.Called(ctx, stationID)
return args.Error(0)
}
func (m *MockQueries) GetStationId(ctx context.Context) (string, error) {
args := m.Called(ctx)
return "", args.Error(0)
}
func (m *MockQueries) GetStationPage(ctx context.Context) (int64, error) {
args := m.Called(ctx)
return 0, args.Error(0)
}
func (m *MockQueries) UpdateStationId(ctx context.Context, stationID string) error {
args := m.Called(ctx, stationID)
return args.Error(0)
}
func (m *MockQueries) UpdateStationPage(ctx context.Context, stationPage int64) error {
args := m.Called(ctx, stationPage)
return args.Error(0)
}
func TestStartup(t *testing.T) {
application := app.NewApp()
ctx := context.TODO()
mockQueries := new(MockQueries)
config := app.Config{
BaseUrl: "",
DefaultStationId: "B01",
TrainUpdateInSeconds: 3000,
TrainRoute: "trainRoute",
IncidentUpdateInSeconds: 3000,
IncidentRoute: "incidentRoute",
StationByIdRoute: "stationByIdRoute",
StationsRoute: "stationsRoute",
SQLiteURL: "sql",
}
// Set expectations for the mock database method calls
mockQueries.On("SetDefaultStationId", ctx, config.DefaultStationId).Return(nil)
application.InitializeApplicationServices(ctx, config, mockQueries)
mockQueries.AssertExpectations(t)
}