MCPcopy Index your code
hub / github.com/coder/coder / TestResourceMonitorQueue

Function TestResourceMonitorQueue

agent/proto/resourcesmonitor/queue_test.go:11–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestResourceMonitorQueue(t *testing.T) {
12 t.Parallel()
13
14 tests := []struct {
15 name string
16 pushCount int
17 expected []resourcesmonitor.Datapoint
18 }{
19 {
20 name: "Push zero",
21 pushCount: 0,
22 expected: []resourcesmonitor.Datapoint{},
23 },
24 {
25 name: "Push less than capacity",
26 pushCount: 3,
27 expected: []resourcesmonitor.Datapoint{
28 {Memory: &resourcesmonitor.MemoryDatapoint{Total: 1, Used: 1}},
29 {Memory: &resourcesmonitor.MemoryDatapoint{Total: 2, Used: 2}},
30 {Memory: &resourcesmonitor.MemoryDatapoint{Total: 3, Used: 3}},
31 },
32 },
33 {
34 name: "Push exactly capacity",
35 pushCount: 20,
36 expected: func() []resourcesmonitor.Datapoint {
37 var result []resourcesmonitor.Datapoint
38 for i := 1; i <= 20; i++ {
39 result = append(result, resourcesmonitor.Datapoint{
40 Memory: &resourcesmonitor.MemoryDatapoint{
41 Total: int64(i),
42 Used: int64(i),
43 },
44 })
45 }
46 return result
47 }(),
48 },
49 {
50 name: "Push more than capacity",
51 pushCount: 25,
52 expected: func() []resourcesmonitor.Datapoint {
53 var result []resourcesmonitor.Datapoint
54 for i := 6; i <= 25; i++ {
55 result = append(result, resourcesmonitor.Datapoint{
56 Memory: &resourcesmonitor.MemoryDatapoint{
57 Total: int64(i),
58 Used: int64(i),
59 },
60 })
61 }
62 return result
63 }(),
64 },
65 }
66
67 for _, tt := range tests {
68 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

PushMethod · 0.95
IsFullMethod · 0.95
ItemsMethod · 0.95
NewQueueFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected