30 lines
648 B
Go
30 lines
648 B
Go
package v1
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"gorm.io/gorm"
|
|
|
|
"github.com/gochat/gochat/internal/model"
|
|
)
|
|
|
|
func createTestChannelInbox(t *testing.T, db *gorm.DB, accountID, channelID uint, name, channelType string, channelConfig map[string]any) *model.Inbox {
|
|
t.Helper()
|
|
|
|
configJSON, err := json.Marshal(channelConfig)
|
|
require.NoError(t, err)
|
|
|
|
inbox := &model.Inbox{
|
|
AccountID: accountID,
|
|
Name: name,
|
|
ChannelType: channelType,
|
|
ChannelID: channelID,
|
|
Enabled: true,
|
|
ChannelConfig: string(configJSON),
|
|
}
|
|
require.NoError(t, db.Create(inbox).Error)
|
|
return inbox
|
|
}
|