-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d62fa8
commit 28c6032
Showing
2 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"google.golang.org/api/calendar/v3" | ||
) | ||
|
||
func TestCreateSlackMessage(t *testing.T) { | ||
var tests = []struct { | ||
name string | ||
events []*calendar.Event | ||
msg string | ||
alt string | ||
want string | ||
}{ | ||
{ | ||
name: "normal", | ||
events: []*calendar.Event{ | ||
{Summary: "Summary1"}, | ||
{Summary: "Summary2"}, | ||
}, | ||
msg: "Test Message", | ||
alt: "Alternative Message", | ||
want: "Test Message\n\n• Summary1\n• Summary2", | ||
}, | ||
{ | ||
name: "empty events", | ||
events: []*calendar.Event{}, | ||
msg: "Test Message", | ||
alt: "Alternative Message", | ||
want: "Alternative Message", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
got := createSlackMessage(tt.events, tt.msg, tt.alt) | ||
if got != tt.want { | ||
t.Errorf("Want '%s', but got '%s'", tt.want, got) | ||
} | ||
} | ||
} |