-
Notifications
You must be signed in to change notification settings - Fork 15
/
dispatch_test.go
54 lines (44 loc) · 1.06 KB
/
dispatch_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
package main
import (
"context"
"testing"
"github.com/recursecenter/pairing-bot/internal/pbtest"
"github.com/recursecenter/pairing-bot/store"
)
func Test_dispatch(t *testing.T) {
ctx := context.Background()
client := pbtest.FirestoreClient(t, ctx)
pl := &PairingLogic{
db: client,
version: "test string",
}
rec := &store.Recurser{
ID: 0,
Name: "Your Name",
Email: "[email protected]",
IsSkippingTomorrow: false,
Schedule: map[string]bool{},
CurrentlyAtRC: false,
IsSubscribed: false,
}
t.Run("version", func(t *testing.T) {
resp, err := pl.dispatch(ctx, "version", nil, rec)
if err != nil {
t.Fatal(err)
}
expected := "test string"
if resp != expected {
t.Errorf("expected %q, got %q", expected, resp)
}
})
t.Run("thanks", func(t *testing.T) {
resp, err := pl.dispatch(ctx, "thanks", nil, rec)
if err != nil {
t.Fatal(err)
}
expected := "You're welcome!"
if resp != expected {
t.Errorf("expected %q, got %q", expected, resp)
}
})
}