From 51f3a9c94ee23562f8717bccd38eb80cf95a2b60 Mon Sep 17 00:00:00 2001 From: Matt Kilgore Date: Thu, 14 Nov 2024 21:48:47 -0500 Subject: [PATCH] fix: some tests --- .../core/services/service_items_attachments.go | 12 ++++++------ backend/internal/data/repo/main_test.go | 2 +- backend/internal/data/repo/repo_documents_test.go | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/internal/core/services/service_items_attachments.go b/backend/internal/core/services/service_items_attachments.go index 5ed2ea6eb..8a217874b 100644 --- a/backend/internal/core/services/service_items_attachments.go +++ b/backend/internal/core/services/service_items_attachments.go @@ -13,23 +13,23 @@ import ( ) func (svc *ItemService) AttachmentPath(ctx context.Context, attachmentID uuid.UUID) (*ent.Document, error) { - attachment, err := svc.repo.Attachments.Get(ctx, attachmentID) + attachments, err := svc.repo.Attachments.Get(ctx, attachmentID) if err != nil { return nil, err } - return attachment.Edges.Document, nil + return attachments.Edges.Document, nil } func (svc *ItemService) AttachmentUpdate(ctx Context, itemID uuid.UUID, data *repo.ItemAttachmentUpdate) (repo.ItemOut, error) { // Update Attachment - attachment, err := svc.repo.Attachments.Update(ctx, data.ID, data) + attachments, err := svc.repo.Attachments.Update(ctx, data.ID, data) if err != nil { return repo.ItemOut{}, err } // Update Document - attDoc := attachment.Edges.Document + attDoc := attachments.Edges.Document _, err = svc.repo.Docs.Rename(ctx, attDoc.ID, data.Title) if err != nil { return repo.ItemOut{}, err @@ -72,7 +72,7 @@ func (svc *ItemService) AttachmentDelete(ctx context.Context, gid, itemID, attac return err } - attachment, err := svc.repo.Attachments.Get(ctx, attachmentID) + attachments, err := svc.repo.Attachments.Get(ctx, attachmentID) if err != nil { return err } @@ -84,7 +84,7 @@ func (svc *ItemService) AttachmentDelete(ctx context.Context, gid, itemID, attac } // Remove File - err = os.Remove(attachment.Edges.Document.Path) + err = os.Remove(attachments.Edges.Document.Path) return err } diff --git a/backend/internal/data/repo/main_test.go b/backend/internal/data/repo/main_test.go index a633d63c1..0727e3f22 100644 --- a/backend/internal/data/repo/main_test.go +++ b/backend/internal/data/repo/main_test.go @@ -55,7 +55,7 @@ func MainNoExit(m *testing.M) int { } tClient = client - tRepos = New(tClient, tbus, os.TempDir()) + tRepos = New(tClient, tbus, "test-store", "file://"+os.TempDir()) defer func() { _ = client.Close() }() bootstrap() diff --git a/backend/internal/data/repo/repo_documents_test.go b/backend/internal/data/repo/repo_documents_test.go index b1d7beba9..e38857b23 100644 --- a/backend/internal/data/repo/repo_documents_test.go +++ b/backend/internal/data/repo/repo_documents_test.go @@ -47,8 +47,9 @@ func useDocs(t *testing.T, num int) []DocumentOut { func TestDocumentRepository_CreateUpdateDelete(t *testing.T) { temp := t.TempDir() r := DocumentRepository{ - db: tClient, - dir: temp, + db: tClient, + storePath: temp, + connString: "file://" + temp, } type args struct {