Files
oci-portal/internal/oci/genai_retire_test.go
T

41 lines
1.3 KiB
Go

package oci
import (
"testing"
"time"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/generativeai"
)
func TestToGenAiModelRetiredFilter(t *testing.T) {
now := time.Date(2026, 7, 9, 0, 0, 0, 0, time.UTC)
past := common.SDKTime{Time: now.Add(-24 * time.Hour)}
future := common.SDKTime{Time: now.Add(30 * 24 * time.Hour)}
chat := []generativeai.ModelCapabilityEnum{generativeai.ModelCapabilityChat}
base := generativeai.ModelSummary{
Id: common.String("ocid1..m"), DisplayName: common.String("meta.llama-x"),
Vendor: common.String("meta"), Capabilities: chat,
LifecycleState: generativeai.ModelLifecycleStateActive,
}
// 已过按需退役时间:不入池(ListModels 仍返回且 state ACTIVE,调用必 404)
retired := base
retired.TimeOnDemandRetired = &past
if _, ok := toGenAiModel(retired, now); ok {
t.Error("已退役模型应被剔除")
}
// 退役时间在未来:入池并携带弃用/退役时间
upcoming := base
upcoming.TimeDeprecated = &past
upcoming.TimeOnDemandRetired = &future
gm, ok := toGenAiModel(upcoming, now)
if !ok || gm.Retired == nil || !gm.Retired.Equal(future.Time) || gm.Deprecated == nil {
t.Fatalf("未退役模型应入池并带时间: ok=%v %+v", ok, gm)
}
// 未宣布任何时间:正常入池
if _, ok := toGenAiModel(base, now); !ok {
t.Error("正常模型应入池")
}
}