Handle special characters in event names (#1)
Co-authored-by: Layla <layla@layla.gg> Reviewed-on: https://gitea.sumulayla.synology.me/layla/birdbot/pulls/1
This commit was merged in pull request #1.
This commit is contained in:
32
core/channel_test.go
Normal file
32
core/channel_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGenerateEventChannelName(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
// Test Valid Address
|
||||
channelName := GenerateEventChannelName("Hello World", "1234 Place Rd, Ann Arbor, MI 00000", time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC))
|
||||
assert.Equal("jan-5-ann-arbor-hello-world-2022", channelName)
|
||||
|
||||
// Test Unparsable
|
||||
// lmanley: Note it'd be nice to expand support for this
|
||||
channelName = GenerateEventChannelName("Hello World", "Michigan Theater, Ann Arbor", time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC))
|
||||
assert.Equal("jan-5-hello-world-2022", channelName)
|
||||
|
||||
// Test Short Location
|
||||
channelName = GenerateEventChannelName("Hello World", "Monroe, MI", time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC))
|
||||
assert.Equal("jan-5-monroe-hello-world-2022", channelName)
|
||||
|
||||
// Test Remote Event
|
||||
channelName = GenerateEventChannelName("Hello World", RemoteLocation, time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC))
|
||||
assert.Equal("jan-5-online-hello-world-2022", channelName)
|
||||
|
||||
channelName = GenerateEventChannelName("Hangout :)", "Quickly Livonia", time.Date(2022, time.January, 5, 0, 0, 0, 0, time.UTC))
|
||||
assert.Equal("jan-5-quickly-livonia-hangout-2022", channelName)
|
||||
}
|
||||
Reference in New Issue
Block a user