Archived
1
0
Fork 0
This repository has been archived on 2024-12-18. You can view files and clone it, but cannot push or open issues or pull requests.
restockbot/notifier_test.go
Julien Riou 0a9ae46d19
Add Telegram Messenger notifications
Signed-off-by: Julien Riou <julien@riou.xyz>
2021-03-24 09:35:37 +01:00

30 lines
689 B
Go

package main
import (
"fmt"
"testing"
)
func TestFormatPrice(t *testing.T) {
tests := []struct {
value float64
currency string
expected string
}{
{999.99, "EUR", "999.99€"},
{999.99, "USD", "$999.99"},
{999.99, "CHF", "CHF999.99"},
{999.99, "", "999.99"},
}
for i, tc := range tests {
t.Run(fmt.Sprintf("TestFormatPrice#%d", i), func(t *testing.T) {
got := formatPrice(tc.value, tc.currency)
if got != tc.expected {
t.Errorf("for value %0.2f and currency %s, got %s, want %s", tc.value, tc.currency, got, tc.expected)
} else {
t.Logf("for value %0.2f and currency %s, got %s, want %s", tc.value, tc.currency, got, tc.expected)
}
})
}
}