randStats returns a random agentproto.Stats
(t *testing.T, opts ...func(*agentproto.Stats))
| 130 | |
| 131 | // randStats returns a random agentproto.Stats |
| 132 | func 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. |
| 160 | type deps struct { |
no test coverage detected