Skip to content

Commit 680c229

Browse files
committed
test: create test for tempPriceStore
1 parent dc9b574 commit 680c229

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

internal/bot/notification_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package bot
2+
3+
import "testing"
4+
5+
func Test_tempPriceStore_storePrice(t1 *testing.T) {
6+
t := tempPriceStore{}
7+
8+
_, exists := t.getPrice(1234, "de")
9+
if exists {
10+
t1.Errorf("Price shouldn't exist yet")
11+
}
12+
13+
t.storePrice(1234, "de", 1.0)
14+
if t.store[1234]["de"] != 1.0 {
15+
t1.Errorf("tempPriceStore.storePrice() failed")
16+
}
17+
18+
_, exists2 := t.getPrice(1234, "de")
19+
if !exists2 {
20+
t1.Errorf("Price must exist now!")
21+
}
22+
23+
_, exists3 := t.getPrice(1234, "at")
24+
if exists3 {
25+
t1.Errorf("Price shouldn't exist for other location!")
26+
}
27+
28+
t.storePrice(1234, "at", 34.56)
29+
if t.store[1234]["at"] != 34.56 {
30+
t1.Errorf("tempPriceStore.storePrice() failed")
31+
}
32+
33+
p, exists4 := t.getPrice(1234, "at")
34+
if !exists4 || p != 34.56 {
35+
t1.Errorf("Price shouldn't exist for other location!")
36+
}
37+
}

0 commit comments

Comments
 (0)