Skip to content

Commit

Permalink
fix: some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tankerkiller125 committed Nov 15, 2024
1 parent 7a3c8bb commit 51f3a9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions backend/internal/core/services/service_items_attachments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion backend/internal/data/repo/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions backend/internal/data/repo/repo_documents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 51f3a9c

Please sign in to comment.