diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 1f2b046..1617baa 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -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) diff --git a/fmt_test.go b/fmt_test.go index 0529da4..3af3cd2 100644 --- a/fmt_test.go +++ b/fmt_test.go @@ -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) + } + }) + } +}