File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ package messagebird
3
3
type Balance struct {
4
4
Payment string
5
5
Type string
6
- Amount int
6
+ Amount float32
7
7
Errors []Error
8
8
}
Original file line number Diff line number Diff line change @@ -5,9 +5,15 @@ import "testing"
5
5
var balanceObject []byte = []byte (`{
6
6
"payment":"prepaid",
7
7
"type":"credits",
8
- "amount":9
8
+ "amount":9.2
9
9
}` )
10
10
11
+ const Epsilon float32 = 0.001
12
+
13
+ func cmpFloat32 (a , b float32 ) bool {
14
+ return (a - b ) < Epsilon && (b - a ) < Epsilon
15
+ }
16
+
11
17
func TestBalance (t * testing.T ) {
12
18
SetServerResponse (200 , balanceObject )
13
19
@@ -22,8 +28,8 @@ func TestBalance(t *testing.T) {
22
28
if balance .Type != "credits" {
23
29
t .Errorf ("Unexpected balance type: %s" , balance .Type )
24
30
}
25
- if balance .Amount != 9 {
26
- t .Errorf ("Unexpected balance amount: %d " , balance .Amount )
31
+ if ! cmpFloat32 ( balance .Amount , 9.2 ) {
32
+ t .Errorf ("Unexpected balance amount: %.2f " , balance .Amount )
27
33
}
28
34
}
29
35
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import (
18
18
)
19
19
20
20
const (
21
- ClientVersion = "2.2.1 "
21
+ ClientVersion = "2.3.0 "
22
22
Endpoint = "https://rest.messagebird.com"
23
23
)
24
24
You can’t perform that action at this time.
0 commit comments