Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions chat/chat_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package chat

import "testing"

func TestHandlePatternMatchRecognizesKnownPricePromptsWithoutData(t *testing.T) {
tests := []struct {
name string
content string
want string
}{
{
name: "bitcoin direct price",
content: "btc price",
want: "I don't have current price data for Bitcoin",
},
{
name: "mention is ignored",
content: "@micro how much is eth",
want: "I don't have current price data for Ethereum",
},
{
name: "case and whitespace are normalized",
content: " PRICE OF GOLD ",
want: "I don't have current price data for Gold",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := handlePatternMatch(tt.content, nil); got != tt.want {
t.Fatalf("handlePatternMatch(%q) = %q, want %q", tt.content, got, tt.want)
}
})
}
}

func TestHandlePatternMatchIgnoresUnsupportedPrompts(t *testing.T) {
tests := []string{
"",
"tell me about bitcoin",
"price",
"a price",
"this symbol is too long price",
}

for _, content := range tests {
t.Run(content, func(t *testing.T) {
if got := handlePatternMatch(content, nil); got != "" {
t.Fatalf("handlePatternMatch(%q) = %q, want empty string", content, got)
}
})
}
}
Loading