(t *testing.T)
| 303 | } |
| 304 | |
| 305 | func TestEscapedEncode(t *testing.T) { |
| 306 | tests := []struct { |
| 307 | name string |
| 308 | format Format |
| 309 | }{ |
| 310 | { |
| 311 | name: "ProtoDelim", |
| 312 | format: FmtProtoDelim, |
| 313 | }, |
| 314 | { |
| 315 | name: "ProtoDelim with escaping underscores", |
| 316 | format: FmtProtoDelim + "; escaping=underscores", |
| 317 | }, |
| 318 | { |
| 319 | name: "ProtoCompact", |
| 320 | format: FmtProtoCompact, |
| 321 | }, |
| 322 | { |
| 323 | name: "ProtoText", |
| 324 | format: FmtProtoText, |
| 325 | }, |
| 326 | { |
| 327 | name: "Text", |
| 328 | format: FmtText, |
| 329 | }, |
| 330 | } |
| 331 | |
| 332 | metric := &dto.MetricFamily{ |
| 333 | Name: proto.String("foo.metric"), |
| 334 | Type: dto.MetricType_UNTYPED.Enum(), |
| 335 | Metric: []*dto.Metric{ |
| 336 | { |
| 337 | Untyped: &dto.Untyped{ |
| 338 | Value: proto.Float64(1.234), |
| 339 | }, |
| 340 | }, |
| 341 | { |
| 342 | Label: []*dto.LabelPair{ |
| 343 | { |
| 344 | Name: proto.String("dotted.label.name"), |
| 345 | Value: proto.String("my.label.value"), |
| 346 | }, |
| 347 | }, |
| 348 | Untyped: &dto.Untyped{ |
| 349 | Value: proto.Float64(8), |
| 350 | }, |
| 351 | }, |
| 352 | }, |
| 353 | } |
| 354 | |
| 355 | for _, tt := range tests { |
| 356 | t.Run(tt.name, func(t *testing.T) { |
| 357 | var buff bytes.Buffer |
| 358 | encoder := NewEncoder(&buff, tt.format) |
| 359 | err := encoder.Encode(metric) |
| 360 | require.NoError(t, err) |
| 361 | |
| 362 | s := buff.String() |
nothing calls this directly
no test coverage detected
searching dependent graphs…