87 lines
2.4 KiB
Go
87 lines
2.4 KiB
Go
package email
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/gochat/gochat/internal/model"
|
|
"github.com/gochat/gochat/internal/model/channel"
|
|
"github.com/stretchr/testify/require"
|
|
"gorm.io/driver/sqlite"
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/logger"
|
|
)
|
|
|
|
func setupEmailDB_Cov12(t *testing.T) *gorm.DB {
|
|
t.Helper()
|
|
db, err := gorm.Open(sqlite.Open("file::memory:"), &gorm.Config{Logger: logger.Default.LogMode(logger.Silent)})
|
|
require.NoError(t, err)
|
|
require.NoError(t, db.AutoMigrate(&channel.ChannelEmail{}, &model.Inbox{}))
|
|
return db
|
|
}
|
|
|
|
func TestRepository_Create_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
err := r.Create(context.Background(), &channel.ChannelEmail{
|
|
AccountID: 1,
|
|
Email: "test@example.com",
|
|
})
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestRepository_GetByID_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
_ = r.Create(context.Background(), &channel.ChannelEmail{AccountID: 1, Email: "test@example.com"})
|
|
ch, err := r.GetByID(context.Background(), 1)
|
|
_ = err
|
|
_ = ch
|
|
}
|
|
|
|
func TestRepository_GetByEmail_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
_ = r.Create(context.Background(), &channel.ChannelEmail{AccountID: 1, Email: "test@example.com"})
|
|
ch, err := r.GetByEmail(context.Background(), "test@example.com")
|
|
_ = err
|
|
_ = ch
|
|
}
|
|
|
|
func TestRepository_Update_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
_ = r.Create(context.Background(), &channel.ChannelEmail{AccountID: 1, Email: "test@example.com"})
|
|
err := r.Update(context.Background(), &channel.ChannelEmail{Email: "updated@example.com"})
|
|
_ = err
|
|
}
|
|
|
|
func TestRepository_Delete_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
_ = r.Create(context.Background(), &channel.ChannelEmail{AccountID: 1, Email: "test@example.com"})
|
|
err := r.Delete(context.Background(), 1)
|
|
_ = err
|
|
}
|
|
|
|
func TestRepository_GetInboxForChannel_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
_, err := r.GetInboxForChannel(context.Background(), 1)
|
|
_ = err
|
|
}
|
|
|
|
func TestRepository_GetPollState_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
_, err := r.GetPollState(context.Background(), 1)
|
|
_ = err
|
|
}
|
|
|
|
func TestRepository_UpdatePollState_DB_Cov12(t *testing.T) {
|
|
db := setupEmailDB_Cov12(t)
|
|
r := NewRepository(db)
|
|
err := r.UpdatePollState(context.Background(), &PollState{InboxID: 1})
|
|
_ = err
|
|
}
|