(t *testing.T)
| 394 | } |
| 395 | |
| 396 | func TestEncode(t *testing.T) { |
| 397 | metric1 := &dto.MetricFamily{ |
| 398 | Name: proto.String("foo_metric"), |
| 399 | Type: dto.MetricType_UNTYPED.Enum(), |
| 400 | Unit: proto.String("seconds"), |
| 401 | Metric: []*dto.Metric{ |
| 402 | { |
| 403 | Untyped: &dto.Untyped{ |
| 404 | Value: proto.Float64(1.234), |
| 405 | }, |
| 406 | }, |
| 407 | }, |
| 408 | } |
| 409 | |
| 410 | scenarios := []struct { |
| 411 | metric *dto.MetricFamily |
| 412 | format Format |
| 413 | options []EncoderOption |
| 414 | expOut string |
| 415 | }{ |
| 416 | // 1: Untyped ProtoDelim |
| 417 | { |
| 418 | metric: metric1, |
| 419 | format: FmtProtoDelim, |
| 420 | }, |
| 421 | // 2: Untyped FmtProtoCompact |
| 422 | { |
| 423 | metric: metric1, |
| 424 | format: FmtProtoCompact, |
| 425 | }, |
| 426 | // 3: Untyped FmtProtoText |
| 427 | { |
| 428 | metric: metric1, |
| 429 | format: FmtProtoText, |
| 430 | }, |
| 431 | // 4: Untyped FmtText |
| 432 | { |
| 433 | metric: metric1, |
| 434 | format: FmtText, |
| 435 | expOut: `# TYPE foo_metric untyped |
| 436 | foo_metric 1.234 |
| 437 | `, |
| 438 | }, |
| 439 | // 5: Untyped FmtOpenMetrics_0_0_1 |
| 440 | { |
| 441 | metric: metric1, |
| 442 | format: FmtOpenMetrics_0_0_1, |
| 443 | expOut: `# TYPE foo_metric unknown |
| 444 | # UNIT foo_metric seconds |
| 445 | foo_metric 1.234 |
| 446 | `, |
| 447 | }, |
| 448 | // 6: Untyped FmtOpenMetrics_1_0_0 |
| 449 | { |
| 450 | metric: metric1, |
| 451 | format: FmtOpenMetrics_1_0_0, |
| 452 | expOut: `# TYPE foo_metric unknown |
| 453 | # UNIT foo_metric seconds |
nothing calls this directly
no test coverage detected