-
Notifications
You must be signed in to change notification settings - Fork 5
/
invoice_test.go
62 lines (54 loc) · 1.49 KB
/
invoice_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 (
"testing"
"time"
)
func TestGetInvoiceNumber(t *testing.T) {
dog := Dog{
ID: 1,
Name: "Fido",
}
date := time.Now()
want := "FID" + date.Format("20060102")
if got := getInvoiceNumber(dog); got != want {
t.Errorf("getInvoiceNumber() = %q, want %q", got, want)
}
}
func TestGetNextMonday(t *testing.T) {
date := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
want := time.Date(2020, 1, 6, 0, 0, 0, 0, time.UTC)
if got := nextMonday(date); got != want {
t.Errorf("getNextMonday() = %q, want %q", got, want)
}
// Check that if the date is already a Monday, it returns the following TestGetNextMonday
date = time.Date(2020, 1, 6, 0, 0, 0, 0, time.UTC)
want = time.Date(2020, 1, 13, 0, 0, 0, 0, time.UTC)
if got := nextMonday(date); got != want {
t.Errorf("getNextMonday() = %q, want %q", got, want)
}
}
// func TestGeneratePdf(t *testing.T) {
// want := "./public/FRE" + time.Now().Format("20060102") + ".pdf"
// got, err := generatePdf(testDog)
// if err != nil {
// t.Errorf("generatePdf() error = %q", err)
// }
// if got != want {
// t.Errorf("generateInvoice() = %q, want %q", got, want)
// }
// }
// func TestSendEmail(t *testing.T) {
// db.Exec("DROP TABLE dogs")
// Init()
// _ = addDog(testDog)
// err := sendEmail(testDog)
// if err != nil {
// t.Errorf("sendEmail() error = %q", err)
// }
// }
// func TestSendInvoice(t *testing.T) {
// err := sendInvoice(testDog.ID)
// if err != nil {
// t.Errorf("sendInvoice() error = %q", err)
// }
// }