-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhatsminer_test.go
123 lines (117 loc) · 2.26 KB
/
whatsminer_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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package minerinfo
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_whatsminer_Type(t *testing.T) {
a := whatsminer{}
got := a.Type()
assert.Equal(t, "Whatsminer", got)
}
func Test_whatsminer_Model_Version(t *testing.T) {
type fields struct {
info minerInfo
}
tests := []struct {
name string
fields fields
wantModel string
wantVersion string
}{
{
name: "Whatsminer M30S++VG30",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{{Model: "M30S++VG30"}},
},
},
wantModel: "M30S++",
wantVersion: "VG30",
},
{
name: "Whatsminer M31S+V40",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{{Model: "M31S+V40"}},
},
},
wantModel: "M31S+",
wantVersion: "V40",
},
{
name: "Whatsminer M31S++V90",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{{Model: "M31S++V90"}},
},
},
wantModel: "M31S++",
wantVersion: "V90",
},
{
name: "Whatsminer M31PV90",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{{Model: "M31PV90"}},
},
},
wantModel: "M31P",
wantVersion: "V90",
},
{
name: "Whatsminer M31PV9V$V##V0",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{{Model: "M31PV9V$V##V0"}},
},
},
wantModel: "M31P",
wantVersion: "V9V$V##V0",
},
{
name: "unknown model",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{},
},
},
wantModel: "Unknown",
},
{
name: "M50_VH20",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{{Model: "M50_VH20"}},
},
},
wantModel: "M50",
wantVersion: "VH20",
},
{
name: "M30S+_VH65",
fields: fields{
info: minerInfo{
Devdetails: []devdetails{{Model: "M30S+_VH65"}},
},
},
wantModel: "M30S+",
wantVersion: "VH65",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := whatsminer{
genericMiner: genericMiner{tt.fields.info},
}
gotModel := a.Model()
assert.Equal(t, tt.wantModel, gotModel)
gotVersion := a.Version()
assert.Equal(t, tt.wantVersion, gotVersion)
})
}
}
func Test_whatsminer_Version(t *testing.T) {
w := whatsminer{}
got := w.Version()
assert.Equal(t, "", got)
}