(t *testing.T)
| 430 | } |
| 431 | |
| 432 | func TestEscapedEncode(t *testing.T) { |
| 433 | tests := []struct { |
| 434 | name string |
| 435 | format Format |
| 436 | }{ |
| 437 | { |
| 438 | name: "ProtoDelim", |
| 439 | format: FmtProtoDelim, |
| 440 | }, |
| 441 | { |
| 442 | name: "ProtoDelim with escaping underscores", |
| 443 | format: FmtProtoDelim + "; escaping=underscores", |
| 444 | }, |
| 445 | { |
| 446 | name: "ProtoCompact", |
| 447 | format: FmtProtoCompact, |
| 448 | }, |
| 449 | { |
| 450 | name: "ProtoText", |
| 451 | format: FmtProtoText, |
| 452 | }, |
| 453 | { |
| 454 | name: "Text", |
| 455 | format: FmtText, |
| 456 | }, |
| 457 | } |
| 458 | |
| 459 | metric := &dto.MetricFamily{ |
| 460 | Name: proto.String("foo.metric"), |
| 461 | Type: dto.MetricType_UNTYPED.Enum(), |
| 462 | Metric: []*dto.Metric{ |
| 463 | { |
| 464 | Untyped: &dto.Untyped{ |
| 465 | Value: proto.Float64(1.234), |
| 466 | }, |
| 467 | }, |
| 468 | { |
| 469 | Label: []*dto.LabelPair{ |
| 470 | { |
| 471 | Name: proto.String("dotted.label.name"), |
| 472 | Value: proto.String("my.label.value"), |
| 473 | }, |
| 474 | }, |
| 475 | Untyped: &dto.Untyped{ |
| 476 | Value: proto.Float64(8), |
| 477 | }, |
| 478 | }, |
| 479 | }, |
| 480 | } |
| 481 | |
| 482 | for _, tt := range tests { |
| 483 | t.Run(tt.name, func(t *testing.T) { |
| 484 | var buff bytes.Buffer |
| 485 | encoder := NewEncoder(&buff, tt.format) |
| 486 | err := encoder.Encode(metric) |
| 487 | require.NoError(t, err) |
| 488 | |
| 489 | s := buff.String() |
nothing calls this directly
no test coverage detected