mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: AI governance into AI Governance (#23553)
This commit is contained in:
@@ -495,15 +495,15 @@ func LicensesEntitlements(
|
||||
case feature.Entitlement == codersdk.EntitlementNotEntitled:
|
||||
// If the limit is not set
|
||||
entitlements.Errors = append(entitlements.Errors,
|
||||
fmt.Sprintf("Your deployment has %d active AI governance seats but the license is not entitled to this feature.", featureArguments.ActiveAISeatCount))
|
||||
fmt.Sprintf("Your deployment has %d active AI Governance seats but the license is not entitled to this feature.", featureArguments.ActiveAISeatCount))
|
||||
case feature.Entitlement == codersdk.EntitlementGracePeriod && feature.Limit != nil:
|
||||
entitlements.Warnings = append(entitlements.Warnings,
|
||||
fmt.Sprintf(
|
||||
"Your deployment has %d active AI governance seats but the license with the limit %d is expired.",
|
||||
"Your deployment has %d active AI Governance seats but the license with the limit %d is expired.",
|
||||
featureArguments.ActiveAISeatCount, *feature.Limit))
|
||||
case feature.Limit != nil && featureArguments.ActiveAISeatCount > *feature.Limit:
|
||||
entitlements.Warnings = append(entitlements.Warnings, fmt.Sprintf(
|
||||
"Your deployment has %d active AI governance seats but is only licensed for %d.",
|
||||
"Your deployment has %d active AI Governance seats but is only licensed for %d.",
|
||||
featureArguments.ActiveAISeatCount, *feature.Limit))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -952,7 +952,7 @@ func TestEntitlements(t *testing.T) {
|
||||
require.EqualValues(t, 100, *aiGovernanceSeatLimit.Limit)
|
||||
|
||||
require.Len(t, entitlements.Warnings, 1)
|
||||
require.Equal(t, "Your deployment has 127 active AI governance seats but is only licensed for 100.", entitlements.Warnings[0])
|
||||
require.Equal(t, "Your deployment has 127 active AI Governance seats but is only licensed for 100.", entitlements.Warnings[0])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1897,7 +1897,7 @@ func TestAIGovernanceAddon(t *testing.T) {
|
||||
|
||||
empty := map[codersdk.FeatureName]bool{}
|
||||
|
||||
t.Run("AIGovernanceAddon enables AI governance features when enablements are set", func(t *testing.T) {
|
||||
t.Run("AIGovernanceAddon enables AI Governance features when enablements are set", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db, _ := dbtestutil.NewDB(t)
|
||||
db.InsertLicense(context.Background(), database.InsertLicenseParams{
|
||||
@@ -1912,7 +1912,7 @@ func TestAIGovernanceAddon(t *testing.T) {
|
||||
Exp: dbtime.Now().Add(time.Hour),
|
||||
})
|
||||
|
||||
// Enable AI governance features in enablements.
|
||||
// Enable AI Governance features in enablements.
|
||||
enablements := map[codersdk.FeatureName]bool{
|
||||
codersdk.FeatureAIBridge: true,
|
||||
codersdk.FeatureBoundary: true,
|
||||
@@ -1935,7 +1935,7 @@ func TestAIGovernanceAddon(t *testing.T) {
|
||||
// require.Equal(t, codersdk.EntitlementEntitled, boundaryFeature.Entitlement, "Boundary should be entitled when addon is present")
|
||||
})
|
||||
|
||||
t.Run("AIGovernanceAddon not present disables AI governance features", func(t *testing.T) {
|
||||
t.Run("AIGovernanceAddon not present disables AI Governance features", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db, _ := dbtestutil.NewDB(t)
|
||||
db.InsertLicense(context.Background(), database.InsertLicenseParams{
|
||||
@@ -1992,7 +1992,7 @@ func TestAIGovernanceAddon(t *testing.T) {
|
||||
require.True(t, entitlements.HasLicense)
|
||||
|
||||
// TODO: Readd this test once AI Bridge is enforced as an add-on license.
|
||||
// AI governance features should be enabled but in grace period.
|
||||
// AI Governance features should be enabled but in grace period.
|
||||
// aibridgeFeature := entitlements.Features[codersdk.FeatureAIBridge]
|
||||
// require.True(t, aibridgeFeature.Enabled, "AI Bridge should be enabled during grace period")
|
||||
// require.Equal(t, codersdk.EntitlementGracePeriod, aibridgeFeature.Entitlement, "AI Bridge should be in grace period")
|
||||
@@ -2060,7 +2060,7 @@ func TestAIGovernanceAddon(t *testing.T) {
|
||||
require.Equal(t, "Feature AI Governance User Limit must be set when using the AI Governance addon.", entitlements.Errors[0])
|
||||
|
||||
// TODO: Readd this test once AI Bridge is enforced as an add-on license.
|
||||
// AI governance features should not be entitled when validation fails.
|
||||
// AI Governance features should not be entitled when validation fails.
|
||||
// aibridgeFeature := entitlements.Features[codersdk.FeatureAIBridge]
|
||||
// require.False(t, aibridgeFeature.Enabled, "AI Bridge should not be enabled when addon validation fails")
|
||||
// require.Equal(t, codersdk.EntitlementNotEntitled, aibridgeFeature.Entitlement, "AI Bridge should not be entitled when addon validation fails")
|
||||
|
||||
Reference in New Issue
Block a user