Add test coverage to core
This commit is contained in:
parent
454b42c2d7
commit
b542fcf901
@ -10,6 +10,7 @@ import (
|
|||||||
func TestGetChannelName(t *testing.T) {
|
func TestGetChannelName(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
// Test Valid Address
|
||||||
event := Event{
|
event := Event{
|
||||||
Name: "Hello World",
|
Name: "Hello World",
|
||||||
Location: "1234 Place Rd, Ann Arbor, MI 00000",
|
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)
|
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{
|
event = Event{
|
||||||
Name: "Hello World",
|
Name: "Hello World",
|
||||||
Location: "Michigan Theater, Ann Arbor",
|
Location: "Michigan Theater, Ann Arbor",
|
||||||
@ -24,4 +27,36 @@ func TestGetChannelName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.Equal("jan-5-hello-world", event.Channel().Name)
|
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())
|
||||||
}
|
}
|
||||||
|
19
core/pointers_test.go
Normal file
19
core/pointers_test.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBool(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
// Test const
|
||||||
|
assert.True(*Bool(true))
|
||||||
|
|
||||||
|
// Test var
|
||||||
|
sample := true
|
||||||
|
assert.True(*Bool(sample))
|
||||||
|
|
||||||
|
}
|
23
core/user_test.go
Normal file
23
core/user_test.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestUserMention(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
// Create user object
|
||||||
|
user := &User{
|
||||||
|
ID: "sample_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal("<@sample_id>", user.Mention())
|
||||||
|
|
||||||
|
// Test null user
|
||||||
|
var nullUser *User = nil
|
||||||
|
assert.NotEmpty(nullUser.Mention())
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user