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

Function randStats

coderd/workspacestats/batcher_internal_test.go:132–157  ·  view source on GitHub ↗

randStats returns a random agentproto.Stats

(t *testing.T, opts ...func(*agentproto.Stats))

Source from the content-addressed store, hash-verified

130
131// randStats returns a random agentproto.Stats
132func randStats(t *testing.T, opts ...func(*agentproto.Stats)) *agentproto.Stats {
133 t.Helper()
134 s := &agentproto.Stats{
135 ConnectionsByProto: map[string]int64{
136 "ssh": mustRandInt64n(t, 9) + 1,
137 "vscode": mustRandInt64n(t, 9) + 1,
138 "jetbrains": mustRandInt64n(t, 9) + 1,
139 "reconnecting_pty": mustRandInt64n(t, 9) + 1,
140 },
141 ConnectionCount: mustRandInt64n(t, 99) + 1,
142 ConnectionMedianLatencyMs: float64(mustRandInt64n(t, 99) + 1),
143 RxPackets: mustRandInt64n(t, 99) + 1,
144 RxBytes: mustRandInt64n(t, 99) + 1,
145 TxPackets: mustRandInt64n(t, 99) + 1,
146 TxBytes: mustRandInt64n(t, 99) + 1,
147 SessionCountVscode: mustRandInt64n(t, 9) + 1,
148 SessionCountJetbrains: mustRandInt64n(t, 9) + 1,
149 SessionCountReconnectingPty: mustRandInt64n(t, 9) + 1,
150 SessionCountSsh: mustRandInt64n(t, 9) + 1,
151 Metrics: []*agentproto.Stats_Metric{},
152 }
153 for _, opt := range opts {
154 opt(s)
155 }
156 return s
157}
158
159// deps is a set of test dependencies.
160type deps struct {

Callers 1

TestBatchStatsFunction · 0.85

Calls 2

mustRandInt64nFunction · 0.85
HelperMethod · 0.65

Tested by

no test coverage detected