初始提交:OCI 面板后端(含 GenAI 网关一期)

This commit is contained in:
Wang Defa
2026-07-09 15:31:04 +08:00
commit b9a3e97e84
168 changed files with 31794 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package oci
import (
"strings"
"testing"
)
func TestRelayEventCondition(t *testing.T) {
tests := []struct {
name string
events []string
want string
}{
{name: "单事件", events: []string{"LaunchInstance"}, want: "data.eventName='LaunchInstance'"},
{
name: "多事件 or 连接",
events: []string{"CreateUser", "DeleteUser"},
want: "data.eventName='CreateUser' or data.eventName='DeleteUser'",
},
{name: "空清单", events: nil, want: ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := RelayEventCondition(tt.events); got != tt.want {
t.Errorf("condition = %q, want %q", got, tt.want)
}
})
}
}
func TestRelayEventConditionQuoting(t *testing.T) {
// 清单值来自代码内常量,不受外部输入;此处只固化引号格式防手滑
cond := RelayEventCondition([]string{"InstanceAction"})
if strings.Count(cond, "'") != 2 {
t.Errorf("单引号数 = %d, want 2 (%s)", strings.Count(cond, "'"), cond)
}
}