feat: opensearch客户端初始化 feat: 索引模板接口 ai: 开发准则 chore: TDD流水线脚本
This commit is contained in:
40
operations/cluster/cluster_test.go
Normal file
40
operations/cluster/cluster_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"es-demo/client"
|
||||
)
|
||||
|
||||
func TestGetInfo(t *testing.T) {
|
||||
// This is a unit test that doesn't require real connection
|
||||
// Integration tests should be run separately
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test in short mode")
|
||||
}
|
||||
|
||||
cfg := &client.Config{
|
||||
Endpoint: "https://example.com",
|
||||
Region: "us-east-1",
|
||||
AccessKey: "test-key",
|
||||
SecretKey: "test-secret",
|
||||
}
|
||||
|
||||
c, err := client.NewClient(cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// This will fail without a real cluster, which is expected in unit tests
|
||||
_, err = GetInfo(ctx, c)
|
||||
// We just verify the method signature is correct
|
||||
// Real integration tests would check actual responses
|
||||
if err == nil {
|
||||
t.Log("GetInfo succeeded (unexpected in unit test)")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user