forked from noebs/noebs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers_test.go
107 lines (98 loc) · 2.32 KB
/
helpers_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package main
import (
"reflect"
"testing"
)
//func Test_handleAdditionalFields(t *testing.T) {
// type args struct {
// fields *ebs_fields.GenericEBSResponseFields
// }
// tests := []struct {
// name string
// args args
// want map[string]interface{}
// }{
// // TODO: Add test cases.
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// if got := handleAdditionalFields(tt.args.fields); !reflect.DeepEqual(got, tt.want) {
// t.Errorf("handleAdditionalFields() = %v, want %v", got, tt.want)
// }
// })
// }
//}
func Test_additionalFieldsToHash(t *testing.T) {
a := `SalesAmount=10.3;FixedFee=22.3;Token=23232;MeterNumber=12345;CustomerName=mohamed`
want := map[string]interface{}{
"SalesAmount": "10.3", "FixedFee": "22.3", "Token": "23232", "MeterNumber": "12345", "CustomerName": "mohamed",
}
tests := []struct {
name string
args string
want map[string]interface{}
}{
{"successful case - nec", a, want},
{"failed case - nec", "", want},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := additionalFieldsToHash(tt.args)
if err != nil {
t.Errorf("Hello there! it worked")
} else if ok := !reflect.DeepEqual(got, tt.want); !ok {
t.Errorf("I cannot pass this test!")
}
})
}
}
//func Test_handleChan(t *testing.T) {
// //var ch = make(chan *ebs_fields.GenericEBSResponseFields)
// f := generateFields()
// billChan <- *f
// want := wantFields()
// tests := []struct {
// name string
// want necBill
// have necBill
// }{
// {"nec successful stuff", want, want},
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// got, ok := handleChan()
// if !ok {
// t.Errorf("there's an error")
// }
// g := got.(necBill)
// if ok := reflect.DeepEqual(g, tt.want); !ok{
// t.Errorf("there is no workign here: have: :%v, %v", g, tt.want)
// }
// })
// }
//}
func wantFields() necBill {
v := necBill{
SalesAmount: 10.3,
FixedFee: 22.3,
Token: "23232",
MeterNumber: "12345",
CustomerName: "mohamed",
}
return v
}
func Test_generateUUID(t *testing.T) {
tests := []struct {
name string
want string
}{
{},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := generateUUID(); got != tt.want {
t.Errorf("generateUUID() = %v, want %v", got, tt.want)
}
})
}
}