William Perron 1 year ago
parent 6e7c4520b1
commit b2ffbedfa5
Signed by: wperron
GPG Key ID: BFDB4EF72D73C5F2

@ -540,7 +540,7 @@ func main() {
if len(absentees) == 0 {
msg = "Everybody can make it next Monday, see you then!"
} else {
msg = fmt.Sprintf("%s can't make it next Monday.", themis.FormatStringSlice(absentees))
msg = fmt.Sprintf("%s can't make it next Monday. :sad:", themis.FormatStringSlice(absentees))
}
_, err = discord.ChannelMessageSend(channelId, msg)

@ -51,3 +51,44 @@ func TestFormatRowsInvalidQuery(t *testing.T) {
_, err = store.db.Query("SELECT count(name), distinct(trade_node) from provinces where region = 'France'")
assert.Error(t, err)
}
func TestFormatStringSlice(t *testing.T) {
tests := []struct {
name string
s []string
want string
}{
{
name: "empty",
s: []string{},
want: "",
},
{
name: "single",
s: []string{"foo"},
want: "foo",
},
{
name: "two",
s: []string{"foo", "bar"},
want: "foo and bar",
},
{
name: "three",
s: []string{"foo", "bar", "baz"},
want: "foo, bar and baz",
},
{
name: "four",
s: []string{"foo", "bar", "baz", "biz"},
want: "foo, bar, baz and biz",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FormatStringSlice(tt.s); got != tt.want {
t.Errorf("FormatStringSlice() = %v, want %v", got, tt.want)
}
})
}
}

Loading…
Cancel
Save