(t *testing.T)
| 201 | } |
| 202 | |
| 203 | func TestEncode(t *testing.T) { |
| 204 | metric1 := &dto.MetricFamily{ |
| 205 | Name: proto.String("foo_metric"), |
| 206 | Type: dto.MetricType_UNTYPED.Enum(), |
| 207 | Unit: proto.String("seconds"), |
| 208 | Metric: []*dto.Metric{ |
| 209 | { |
| 210 | Untyped: &dto.Untyped{ |
| 211 | Value: proto.Float64(1.234), |
| 212 | }, |
| 213 | }, |
| 214 | }, |
| 215 | } |
| 216 | |
| 217 | scenarios := []struct { |
| 218 | metric *dto.MetricFamily |
| 219 | format Format |
| 220 | options []EncoderOption |
| 221 | expOut string |
| 222 | }{ |
| 223 | // 1: Untyped ProtoDelim |
| 224 | { |
| 225 | metric: metric1, |
| 226 | format: FmtProtoDelim, |
| 227 | }, |
| 228 | // 2: Untyped FmtProtoCompact |
| 229 | { |
| 230 | metric: metric1, |
| 231 | format: FmtProtoCompact, |
| 232 | }, |
| 233 | // 3: Untyped FmtProtoText |
| 234 | { |
| 235 | metric: metric1, |
| 236 | format: FmtProtoText, |
| 237 | }, |
| 238 | // 4: Untyped FmtText |
| 239 | { |
| 240 | metric: metric1, |
| 241 | format: FmtText, |
| 242 | expOut: `# TYPE foo_metric untyped |
| 243 | foo_metric 1.234 |
| 244 | `, |
| 245 | }, |
| 246 | // 5: Untyped FmtOpenMetrics_0_0_1 |
| 247 | { |
| 248 | metric: metric1, |
| 249 | format: FmtOpenMetrics_0_0_1, |
| 250 | expOut: `# TYPE foo_metric unknown |
| 251 | # UNIT foo_metric seconds |
| 252 | foo_metric 1.234 |
| 253 | `, |
| 254 | }, |
| 255 | // 6: Untyped FmtOpenMetrics_1_0_0 |
| 256 | { |
| 257 | metric: metric1, |
| 258 | format: FmtOpenMetrics_1_0_0, |
| 259 | expOut: `# TYPE foo_metric unknown |
| 260 | # UNIT foo_metric seconds |
nothing calls this directly
no test coverage detected
searching dependent graphs…