(t *testing.T)
| 184 | } |
| 185 | |
| 186 | func TestContainerStatsContextWrite(t *testing.T) { |
| 187 | tt := []struct { |
| 188 | context formatter.Context |
| 189 | expected string |
| 190 | }{ |
| 191 | { |
| 192 | formatter.Context{Format: "{{InvalidFunction}}"}, |
| 193 | `template parsing error: template: :1: function "InvalidFunction" not defined`, |
| 194 | }, |
| 195 | { |
| 196 | formatter.Context{Format: "{{nil}}"}, |
| 197 | `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`, |
| 198 | }, |
| 199 | { |
| 200 | formatter.Context{Format: "table {{.MemUsage}}"}, |
| 201 | `MEM USAGE / LIMIT |
| 202 | 20B / 20B |
| 203 | -- / -- |
| 204 | `, |
| 205 | }, |
| 206 | { |
| 207 | formatter.Context{Format: "{{.Container}} {{.ID}} {{.Name}}"}, |
| 208 | `container1 abcdef foo |
| 209 | container2 -- |
| 210 | `, |
| 211 | }, |
| 212 | { |
| 213 | formatter.Context{Format: "{{.Container}} {{.CPUPerc}}"}, |
| 214 | `container1 20.00% |
| 215 | container2 -- |
| 216 | `, |
| 217 | }, |
| 218 | } |
| 219 | |
| 220 | for _, te := range tt { |
| 221 | stats := []StatsEntry{ |
| 222 | { |
| 223 | Container: "container1", |
| 224 | ID: "abcdef", |
| 225 | Name: "/foo", |
| 226 | CPUPercentage: 20, |
| 227 | Memory: 20, |
| 228 | MemoryLimit: 20, |
| 229 | MemoryPercentage: 20, |
| 230 | NetworkRx: 20, |
| 231 | NetworkTx: 20, |
| 232 | BlockRead: 20, |
| 233 | BlockWrite: 20, |
| 234 | PidsCurrent: 2, |
| 235 | IsInvalid: false, |
| 236 | }, |
| 237 | { |
| 238 | Container: "container2", |
| 239 | CPUPercentage: 30, |
| 240 | Memory: 30, |
| 241 | MemoryLimit: 30, |
| 242 | MemoryPercentage: 30, |
| 243 | NetworkRx: 30, |
nothing calls this directly
no test coverage detected
searching dependent graphs…