diff --git a/backend/internal/core/services/service_items_attachments.go b/backend/internal/core/services/service_items_attachments.go index 5ed2ea6e..8a217874 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 a633d63c..0727e3f2 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 b1d7beba..e38857b2 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 {