-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_test.go
48 lines (43 loc) · 963 Bytes
/
app_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
package mtp
import (
"testing"
"time"
"go.uber.org/zap"
)
func TestAppMockEndToEnd(t *testing.T) {
// Setup
waiter := &WaitFixed{WaitDuration: time.Second}
failer := &FailRandom{FailRate: 0.05}
zapLogger, err := zap.NewProduction()
if err != nil {
t.Fatalf("Could not create Zap logger, err=%s", err)
}
logger := zapLogger.Sugar()
hackerNews := &HackerNewsMock{
articles: map[string]Article{},
waiter: waiter,
failer: failer,
logger: logger,
}
database := &DatabaseMock{
articles: map[string]Article{},
waiter: waiter,
failer: failer,
logger: logger,
}
app := &App{
hackerNewsScraper: hackerNews,
databaseConnecter: database,
logger: logger,
}
// Run the test
tester := &AppEndToEndTester{
app: app,
HackerNewsFeeder: hackerNews,
DatabaseTester: database,
}
err = tester.TestEndToEnd()
if err != nil {
t.Fatalf("TestEndToEnd: Expected err=nil, got err=%s", err)
}
}