Add test coverage to core

This commit is contained in:
2022-10-30 01:16:31 -04:00
parent 454b42c2d7
commit b542fcf901
4 changed files with 77 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
func TestGetChannelName(t *testing.T) {
assert := assert.New(t)
// Test Valid Address
event := Event{
Name: "Hello World",
Location: "1234 Place Rd, Ann Arbor, MI 00000",
@@ -17,6 +18,8 @@ func TestGetChannelName(t *testing.T) {
}
assert.Equal("jan-5-ann-arbor-hello-world", event.Channel().Name)
// Test Unparsable Location
// lmanley: Note it'd be nice to expand support for this
event = Event{
Name: "Hello World",
Location: "Michigan Theater, Ann Arbor",
@@ -24,4 +27,36 @@ func TestGetChannelName(t *testing.T) {
}
assert.Equal("jan-5-hello-world", event.Channel().Name)
// Test Short Location
event = Event{
Name: "Hello World",
Location: "Monroe, MI",
DateTime: time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC),
}
assert.Equal("jan-5-monroe-hello-world", event.Channel().Name)
// Test Short Location
event = Event{
Name: "Hello World",
Location: "Monroe St, Monroe , MI",
DateTime: time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC),
}
assert.Equal("jan-5-monroe-hello-world", event.Channel().Name)
// Test Remote Event
event = Event{
Name: "Hello World",
Location: REMOTE_LOCATION,
DateTime: time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC),
}
assert.Equal("jan-5-online-hello-world", event.Channel().Name)
}
func TestMonthPrefix(t *testing.T) {
assert := assert.New(t)
event := Event{
DateTime: time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC),
}
assert.Equal("jan", event.GetMonthPrefix())
}