-
Notifications
You must be signed in to change notification settings - Fork 3
/
Plan_test.go
74 lines (63 loc) · 1.97 KB
/
Plan_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package HologramGo
import (
"encoding/json"
"github.com/hologram-io/hologram-go"
"fmt"
"io/ioutil"
"testing"
)
func TestGetDeviceDataPlan(t *testing.T) {
file, e := ioutil.ReadFile("json/plan.json")
if e != nil {
fmt.Printf("Error opening file: %v\n", e)
}
var payload = HologramGo.Placeholder{}
err := json.Unmarshal(file, &payload)
if err != nil {
fmt.Println("Unable to parse file")
}
var plans = (payload["data"].([]interface{}))
var plan = (HologramGo.Plan)(plans[0].(map[string]interface{}))
// Test for data plan id
expectedFloat := (float64)(51)
returnedFloat := plan.GetDataPlanId()
if expectedFloat != returnedFloat {
t.Fatalf("Expected %s, got %s", expectedFloat, returnedFloat)
}
// Test for data plan partner id.
expectedFloat = (float64)(1)
returnedFloat = plan.GetDataPlanPartnerId()
if expectedFloat != returnedFloat {
t.Fatalf("Expected %s, got %s", expectedFloat, returnedFloat)
}
// Test for data plan name.
expectedString := "1 MB"
returnedString := plan.GetDataPlanName()
if expectedString != returnedString {
t.Fatalf("Expected %s, got %s", expectedString, returnedString)
}
// Test for data plan subscription
expectedString = ""
returnedString = plan.GetDataPlanDescription()
if expectedString != returnedString {
t.Fatalf("Expected %s, got %s", expectedString, returnedString)
}
// Test for data plan size
expectedFloat = (float64)(1000000)
returnedFloat = plan.GetDataPlanSize()
if expectedFloat != returnedFloat {
t.Fatalf("Expected %s, got %s", expectedFloat, returnedFloat)
}
// Test for data plan billing period
expectedFloat = (float64)(24)
returnedFloat = plan.GetDataPlanBillingPeriod()
if expectedFloat != returnedFloat {
t.Fatalf("Expected %s, got %s", expectedFloat, returnedFloat)
}
// Test for data plan carrier id.
expectedFloat = (float64)(1)
returnedFloat = plan.GetDataPlanCarrierId()
if expectedFloat != returnedFloat {
t.Fatalf("Expected %s, got %s", expectedFloat, returnedFloat)
}
}