feat: opensearch客户端初始化 feat: 索引模板接口 ai: 开发准则 chore: TDD流水线脚本

This commit is contained in:
mouseleee
2025-11-16 22:17:16 +08:00
commit da3883205c
18 changed files with 2707 additions and 0 deletions

View 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)")
}
}