-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_test.go
61 lines (49 loc) · 1.35 KB
/
email_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
package wlbdqm
import (
"log"
"os"
"testing"
)
func TestPrepareDiskInsufficientContent(t *testing.T) {
contentItem := ContentItem{
MaxPercentage: 80,
DPercentage: 81.22,
FPercentage: 15.01,
DPOutput: `Filesystem type blocks quota limit in_doubt grace | files quota limit in_doubt grace Remarks
public USR 15.39T 45T 50T 11.71G expired | 645614 7500000 8000000 14238 none`,
}
content, err := PrepareDiskInsufficientContent(contentItem)
if err != nil {
log.Fatal(err)
}
log.Println(content)
}
func TestSendEmail(t *testing.T) {
var mockOutput = `Filesystem type blocks quota limit in_doubt grace | files quota limit in_doubt grace Remarks
public USR 15.39T 45T 50T 11.71G expired | 645614 7500000 8000000 14238 none`
dq, err := ParseDiskQuotaOutput(mockOutput)
if err != nil {
t.Fatal(err)
}
t.Log(dq.HTMLTable())
contentItem := ContentItem{
MaxPercentage: 80,
DPercentage: 81.22,
FPercentage: 15.01,
DPOutput: dq.HTMLTable(),
}
content, err := PrepareDiskInsufficientContent(contentItem)
if err != nil {
log.Fatal(err)
}
err = os.Setenv(MailKeyFrom, "a2htray@outlook.com")
err = os.Setenv(MailKeyPassword, "MY PASSWORD")
err = os.Setenv(MailKeyHost, "smtp-mail.outlook.com")
err = os.Setenv(MailKeyPort, "587")
err = SendEmail([]string{
"a2htray@outlook.com",
}, content)
if err != nil {
log.Fatal(err)
}
}