Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package telegram |
||
2 | |||
3 | import ( |
||
4 | "os" |
||
5 | "testing" |
||
6 | ) |
||
7 | |||
8 | func TestTodayIsReportCheckDay(t *testing.T) { |
||
9 | t.Parallel() |
||
10 | os.Setenv("DAYS_FOR_REPORT_CHECK", "Saturday,Sunday,Monday") |
||
11 | |||
12 | for _, dayOk := range []string{"Sunday", "Monday", "Saturday"} { |
||
13 | t.Run(dayOk+" day", func(t *testing.T) { |
||
14 | if !todayIsReportCheckDay(dayOk) { |
||
15 | t.Errorf("todayIsReportCheckDay for value %s must return true", dayOk) |
||
16 | } |
||
17 | }) |
||
18 | } |
||
19 | |||
20 | for _, day := range []string{"Tuesday", "Wednesday", "Thursday", "Friday"} { |
||
21 | t.Run(day+" day", func(t *testing.T) { |
||
22 | if todayIsReportCheckDay(day) { |
||
23 | t.Errorf("todayIsReportCheckDay for value %s must return false", day) |
||
24 | } |
||
25 | }) |
||
26 | } |
||
27 | } |
||
28 | |||
29 | func TestGetChatId(t *testing.T) { |
||
30 | t.Parallel() |
||
31 | os.Setenv("BOT_CHAT_ID", "543210") |
||
32 | chatID := getChatID() |
||
33 | |||
34 | if chatID != 543210 { |
||
35 | t.Errorf("The result of getChatID function must be 543210, but %v returned", chatID) |
||
36 | } |
||
38 |