============================================================================ 第一部分:正确性测试 — 基本功能 ============================================================================
(t *testing.T)
| 356 | // ============================================================================ |
| 357 | |
| 358 | func TestLabel_AddAndGet(t *testing.T) { |
| 359 | l := newTestLabel() |
| 360 | batch := generateProtoLabels(100) |
| 361 | populateLabelDeps(l, 100) |
| 362 | |
| 363 | l.Add(batch) |
| 364 | |
| 365 | for _, item := range batch { |
| 366 | id, ok := l.GetIDByKey(NewLabelKey(item.GetName(), item.GetValue())) |
| 367 | assert.True(t, ok) |
| 368 | assert.Equal(t, int(item.GetId()), id) |
| 369 | } |
| 370 | |
| 371 | // 不存在的 key |
| 372 | _, ok := l.GetIDByKey(NewLabelKey("nonexistent", "nonexistent")) |
| 373 | assert.False(t, ok) |
| 374 | } |
| 375 | |
| 376 | func TestMetricName_AddAndGet(t *testing.T) { |
| 377 | mn := newTestMetricName() |
nothing calls this directly
no test coverage detected