feat: add passive channel monitoring mode (#5592)
* feat: add passive channel monitoring mode * fix: clarify passive monitor mode copy
This commit is contained in:
@@ -6,8 +6,10 @@ import (
|
||||
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
"github.com/QuantumNous/new-api/dto"
|
||||
"github.com/QuantumNous/new-api/model"
|
||||
"github.com/QuantumNous/new-api/pkg/billingexpr"
|
||||
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
||||
"github.com/QuantumNous/new-api/setting/operation_setting"
|
||||
"github.com/QuantumNous/new-api/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -80,3 +82,30 @@ func TestResolveChannelTestUserIDUsesRequestUser(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, userID)
|
||||
}
|
||||
|
||||
func TestSelectChannelsForAutomaticTestPassiveRecoveryOnlyUsesAutoDisabled(t *testing.T) {
|
||||
channels := []*model.Channel{
|
||||
{Id: 1, Status: common.ChannelStatusEnabled},
|
||||
{Id: 2, Status: common.ChannelStatusAutoDisabled},
|
||||
{Id: 3, Status: common.ChannelStatusManuallyDisabled},
|
||||
}
|
||||
|
||||
selected := selectChannelsForAutomaticTest(channels, operation_setting.ChannelTestModePassiveRecovery)
|
||||
|
||||
require.Len(t, selected, 1)
|
||||
require.Equal(t, 2, selected[0].Id)
|
||||
}
|
||||
|
||||
func TestSelectChannelsForAutomaticTestScheduledSkipsManualDisabled(t *testing.T) {
|
||||
channels := []*model.Channel{
|
||||
{Id: 1, Status: common.ChannelStatusEnabled},
|
||||
{Id: 2, Status: common.ChannelStatusAutoDisabled},
|
||||
{Id: 3, Status: common.ChannelStatusManuallyDisabled},
|
||||
}
|
||||
|
||||
selected := selectChannelsForAutomaticTest(channels, operation_setting.ChannelTestModeScheduledAll)
|
||||
|
||||
require.Len(t, selected, 2)
|
||||
require.Equal(t, 1, selected[0].Id)
|
||||
require.Equal(t, 2, selected[1].Id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user