Files
new-api-custom/model/ability_group_test.go
T
Codex bb7968b612
Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
feat: publish v1.0.0-rc.36-custom.1
2026-09-11 05:07:48 +08:00

32 lines
1.3 KiB
Go

package model
import (
"testing"
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/constant"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetEnabledGroupSetRequiresEnabledAbilityAndChannel(t *testing.T) {
resetPricingEndpointTestTables(t)
require.NoError(t, DB.Create(&[]Channel{
{Id: 1, Type: constant.ChannelTypeOpenAI, Key: "active-key", Name: "active", Status: common.ChannelStatusEnabled},
{Id: 2, Type: constant.ChannelTypeOpenAI, Key: "manual-key", Name: "manual", Status: common.ChannelStatusManuallyDisabled},
{Id: 3, Type: constant.ChannelTypeOpenAI, Key: "auto-key", Name: "auto", Status: common.ChannelStatusAutoDisabled},
{Id: 4, Type: constant.ChannelTypeOpenAI, Key: "ability-key", Name: "ability", Status: common.ChannelStatusEnabled},
}).Error)
require.NoError(t, DB.Create(&[]Ability{
{Group: "active", Model: "gpt-active", ChannelId: 1, Enabled: true},
{Group: "manual-disabled", Model: "gpt-manual", ChannelId: 2, Enabled: true},
{Group: "auto-disabled", Model: "gpt-auto", ChannelId: 3, Enabled: true},
{Group: "ability-disabled", Model: "gpt-ability", ChannelId: 4, Enabled: false},
}).Error)
groups, err := GetEnabledGroupSet()
require.NoError(t, err)
assert.Equal(t, map[string]struct{}{"active": {}}, groups)
}