feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
This commit is contained in:
41
internal/repository/social_account_repo_constructor_test.go
Normal file
41
internal/repository/social_account_repo_constructor_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package repository
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNewSocialAccountRepository_AcceptsGormDB(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
|
||||
repo, err := NewSocialAccountRepository(db)
|
||||
if err != nil {
|
||||
t.Fatalf("expected constructor to succeed: %v", err)
|
||||
}
|
||||
if repo == nil {
|
||||
t.Fatal("expected repository instance")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewSocialAccountRepository_AcceptsSQLDB(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
t.Fatalf("expected sql db handle: %v", err)
|
||||
}
|
||||
|
||||
repo, err := NewSocialAccountRepository(sqlDB)
|
||||
if err != nil {
|
||||
t.Fatalf("expected constructor to succeed: %v", err)
|
||||
}
|
||||
if repo == nil {
|
||||
t.Fatal("expected repository instance")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewSocialAccountRepository_RejectsUnsupportedType(t *testing.T) {
|
||||
repo, err := NewSocialAccountRepository(struct{}{})
|
||||
if err == nil {
|
||||
t.Fatal("expected constructor error")
|
||||
}
|
||||
if repo != nil {
|
||||
t.Fatal("did not expect repository instance")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user