9
9
10
10
"github.com/stretchr/testify/require"
11
11
12
+ "github.com/coder/coder/cli/clistat"
12
13
"github.com/coder/coder/cli/clitest"
13
14
"github.com/coder/coder/testutil"
14
15
)
@@ -31,7 +32,7 @@ func TestStatCmd(t *testing.T) {
31
32
s := buf .String ()
32
33
require .NotEmpty (t , s )
33
34
// Must be valid JSON
34
- tmp := make ([]struct {} , 0 )
35
+ tmp := make ([]clistat. Result , 0 )
35
36
require .NoError (t , json .NewDecoder (strings .NewReader (s )).Decode (& tmp ))
36
37
})
37
38
t .Run ("Table" , func (t * testing.T ) {
@@ -92,8 +93,12 @@ func TestStatCPUCmd(t *testing.T) {
92
93
err := inv .WithContext (ctx ).Run ()
93
94
require .NoError (t , err )
94
95
s := buf .String ()
95
- tmp := struct {} {}
96
+ tmp := clistat. Result {}
96
97
require .NoError (t , json .NewDecoder (strings .NewReader (s )).Decode (& tmp ))
98
+ require .NotZero (t , tmp .Used )
99
+ require .NotNil (t , tmp .Total )
100
+ require .NotZero (t , * tmp .Total )
101
+ require .Equal (t , "cores" , tmp .Unit )
97
102
})
98
103
}
99
104
@@ -123,8 +128,12 @@ func TestStatMemCmd(t *testing.T) {
123
128
err := inv .WithContext (ctx ).Run ()
124
129
require .NoError (t , err )
125
130
s := buf .String ()
126
- tmp := struct {} {}
131
+ tmp := clistat. Result {}
127
132
require .NoError (t , json .NewDecoder (strings .NewReader (s )).Decode (& tmp ))
133
+ require .NotZero (t , tmp .Used )
134
+ require .NotNil (t , tmp .Total )
135
+ require .NotZero (t , * tmp .Total )
136
+ require .Equal (t , "B" , tmp .Unit )
128
137
})
129
138
}
130
139
@@ -154,7 +163,11 @@ func TestStatDiskCmd(t *testing.T) {
154
163
err := inv .WithContext (ctx ).Run ()
155
164
require .NoError (t , err )
156
165
s := buf .String ()
157
- tmp := struct {} {}
166
+ tmp := clistat. Result {}
158
167
require .NoError (t , json .NewDecoder (strings .NewReader (s )).Decode (& tmp ))
168
+ require .NotZero (t , tmp .Used )
169
+ require .NotNil (t , tmp .Total )
170
+ require .NotZero (t , * tmp .Total )
171
+ require .Equal (t , "B" , tmp .Unit )
159
172
})
160
173
}
0 commit comments