From b11530867c169325ff5bf63c27b68f7db2182881 Mon Sep 17 00:00:00 2001 From: Milos Gagovic Date: Mon, 23 Oct 2023 23:09:28 +0200 Subject: [PATCH] Repo findall test added --- .../repository/repository_test.go | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 domain/redirectdefinition/repository/repository_test.go diff --git a/domain/redirectdefinition/repository/repository_test.go b/domain/redirectdefinition/repository/repository_test.go new file mode 100644 index 0000000..55c6c81 --- /dev/null +++ b/domain/redirectdefinition/repository/repository_test.go @@ -0,0 +1,35 @@ +package redirectrepository_test + +import ( + "context" + "fmt" + "testing" + + keelmongo "github.com/foomo/keel/persistence/mongo" + redirectrepository "github.com/foomo/redirects/domain/redirectdefinition/repository" + "github.com/stretchr/testify/assert" + "go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo" + "go.uber.org/zap" +) + +func TestGetAllRedirects(t *testing.T) { + l := zap.L() + mongoURI := "mongodb://localhost:27017/local" + remotePersistor, err := keelmongo.New( + context.Background(), + mongoURI, + keelmongo.WithOtelOptions( + otelmongo.WithCommandAttributeDisabled(true), + ), + ) + assert.NoError(t, err) + // create repository + repo, err := redirectrepository.NewRedirectsDefinitionRepository(l, remotePersistor) + if err != nil { + fmt.Print(err) + } + redirectDefinitions, err := repo.FindAll(context.Background()) + assert.Equal(t, 0, len(*redirectDefinitions)) + assert.NoError(t, err) + +}