fixed doc env vars + mongo v2 migration
This commit is contained in:
@@ -4,11 +4,11 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestAccountBoundDBImp_Enforce(t *testing.T) {
|
||||
logger := mlogger.Logger(zap.NewNop())
|
||||
db := &AccountBoundDBImp[model.AccountBoundStorable]{
|
||||
Logger: logger,
|
||||
PermissionRef: primitive.NewObjectID(),
|
||||
PermissionRef: bson.NewObjectID(),
|
||||
Collection: "test_collection",
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestAccountBoundDBImp_Enforce(t *testing.T) {
|
||||
|
||||
t.Run("PermissionRefSet", func(t *testing.T) {
|
||||
// Test that PermissionRef is properly set
|
||||
assert.NotEqual(t, primitive.NilObjectID, db.PermissionRef)
|
||||
assert.NotEqual(t, bson.NilObjectID, db.PermissionRef)
|
||||
})
|
||||
|
||||
t.Run("CollectionSet", func(t *testing.T) {
|
||||
@@ -43,7 +43,7 @@ func TestAccountBoundDBImp_InterfaceCompliance(t *testing.T) {
|
||||
logger := mlogger.Logger(zap.NewNop())
|
||||
db := &AccountBoundDBImp[model.AccountBoundStorable]{
|
||||
Logger: logger,
|
||||
PermissionRef: primitive.NewObjectID(),
|
||||
PermissionRef: bson.NewObjectID(),
|
||||
Collection: "test_collection",
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestAccountBoundDBImp_InterfaceCompliance(t *testing.T) {
|
||||
// Test that the struct can be initialized
|
||||
assert.NotNil(t, db)
|
||||
assert.NotNil(t, db.Logger)
|
||||
assert.NotEqual(t, primitive.NilObjectID, db.PermissionRef)
|
||||
assert.NotEqual(t, bson.NilObjectID, db.PermissionRef)
|
||||
assert.NotEmpty(t, db.Collection)
|
||||
})
|
||||
|
||||
@@ -65,14 +65,14 @@ func TestAccountBoundDBImp_InterfaceCompliance(t *testing.T) {
|
||||
func TestAccountBoundDBImp_ErrorHandling(t *testing.T) {
|
||||
t.Run("AccessDeniedError", func(t *testing.T) {
|
||||
// Test that AccessDenied error is properly created
|
||||
err := merrors.AccessDenied("test_collection", "read", primitive.NilObjectID)
|
||||
err := merrors.AccessDenied("test_collection", "read", bson.NilObjectID)
|
||||
assert.Error(t, err)
|
||||
assert.True(t, errors.Is(err, merrors.ErrAccessDenied))
|
||||
})
|
||||
|
||||
t.Run("ErrorTypeChecking", func(t *testing.T) {
|
||||
// Test error type checking
|
||||
accessDeniedErr := merrors.AccessDenied("test", "read", primitive.NilObjectID)
|
||||
accessDeniedErr := merrors.AccessDenied("test", "read", bson.NilObjectID)
|
||||
otherErr := errors.New("other error")
|
||||
|
||||
assert.True(t, errors.Is(accessDeniedErr, merrors.ErrAccessDenied))
|
||||
|
||||
Reference in New Issue
Block a user