修改代码注释为中文
This commit is contained in:
@@ -11,13 +11,13 @@ func TestRegistry_Register(t *testing.T) {
|
||||
mock := &mockCollector{name: "test"}
|
||||
err := r.Register(mock)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
t.Fatalf("注册时不应出错: %v", err)
|
||||
}
|
||||
|
||||
// Duplicate registration should fail
|
||||
// 重复注册应该失败
|
||||
err = r.Register(mock)
|
||||
if err == nil {
|
||||
t.Fatal("expected error for duplicate registration")
|
||||
t.Fatal("重复注册应该返回错误")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,15 +29,15 @@ func TestRegistry_Get(t *testing.T) {
|
||||
|
||||
c, ok := r.Get("test")
|
||||
if !ok {
|
||||
t.Fatal("expected to find collector")
|
||||
t.Fatal("应该能找到已注册的采集器")
|
||||
}
|
||||
if c.Name() != "test" {
|
||||
t.Fatalf("expected name 'test', got '%s'", c.Name())
|
||||
t.Fatalf("期望名称为 'test',实际为 '%s'", c.Name())
|
||||
}
|
||||
|
||||
_, ok = r.Get("nonexistent")
|
||||
if ok {
|
||||
t.Fatal("expected not to find collector")
|
||||
t.Fatal("不应该找到未注册的采集器")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,16 +50,16 @@ func TestRegistry_List(t *testing.T) {
|
||||
|
||||
all := r.List()
|
||||
if len(all) != 3 {
|
||||
t.Fatalf("expected 3 collectors, got %d", len(all))
|
||||
t.Fatalf("期望 3 个采集器,实际为 %d 个", len(all))
|
||||
}
|
||||
|
||||
runtime := r.ListByCategory(CategoryRuntime)
|
||||
if len(runtime) != 2 {
|
||||
t.Fatalf("expected 2 runtime collectors, got %d", len(runtime))
|
||||
t.Fatalf("期望 2 个运行时采集器,实际为 %d 个", len(runtime))
|
||||
}
|
||||
}
|
||||
|
||||
// mockCollector implements Collector for testing
|
||||
// mockCollector 用于测试的模拟采集器
|
||||
type mockCollector struct {
|
||||
name string
|
||||
category Category
|
||||
@@ -68,7 +68,7 @@ type mockCollector struct {
|
||||
|
||||
func (m *mockCollector) Name() string { return m.name }
|
||||
func (m *mockCollector) DisplayName() string { return m.name }
|
||||
func (m *mockCollector) Description() string { return "mock collector" }
|
||||
func (m *mockCollector) Description() string { return "模拟采集器" }
|
||||
func (m *mockCollector) Category() Category { return m.category }
|
||||
func (m *mockCollector) IsAvailable(ctx context.Context) bool {
|
||||
return m.available
|
||||
|
||||
Reference in New Issue
Block a user