From 978126848512b3e78f95358105b9e4b56b872592 Mon Sep 17 00:00:00 2001 From: Kristian Borgwarth <10348902@pm.me> Date: Sun, 12 Apr 2026 02:54:17 +0200 Subject: [PATCH] fix(test): new di setup for integration tests --- .../create_note_handler_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test/test_integration/create_note_handler_test.go b/test/test_integration/create_note_handler_test.go index b58017a..88eca92 100644 --- a/test/test_integration/create_note_handler_test.go +++ b/test/test_integration/create_note_handler_test.go @@ -7,13 +7,22 @@ import ( "testing" "github.com/KristianJBorgwarth/dendrite.daemon/core/handlers/note" + "github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +func newCreateNoteHandler() *note.CreateNoteHandler { + return note.NewCreateNoteHandler( + repositories.NewUnitOfWork(), + repositories.NewTagRepository(), + repositories.NewNoteRepository(), + ) +} + func TestCreateNoteHandler_NoTemplate_CreatesNoteFileAndReturnsPath(t *testing.T) { // Arrange - handler := note.NewCreateNoteHandler() + handler := newCreateNoteHandler() vaultPath := Fixture.VaultStore.Config.VaultPath() notePath := filepath.Join(vaultPath, "my-note.md") @@ -40,7 +49,7 @@ func TestCreateNoteHandler_NoTemplate_CreatesNoteFileAndReturnsPath(t *testing.T func TestCreateNoteHandler_WithTemplate_CreatesNoteFileWithTagsAndReturnsPath(t *testing.T) { // Arrange - handler := note.NewCreateNoteHandler() + handler := newCreateNoteHandler() vaultPath := Fixture.VaultStore.Config.VaultPath() templateDir := Fixture.VaultStore.Config.TemplateDirectory() @@ -89,7 +98,7 @@ func TestCreateNoteHandler_WithTemplate_CreatesNoteFileWithTagsAndReturnsPath(t func TestCreateNoteHandler_DuplicateSlug_Upserts(t *testing.T) { // Arrange - handler := note.NewCreateNoteHandler() + handler := newCreateNoteHandler() vaultPath := Fixture.VaultStore.Config.VaultPath() subDir := "dup-dir" @@ -123,7 +132,7 @@ func TestCreateNoteHandler_DuplicateSlug_Upserts(t *testing.T) { func TestCreateNoteHandler_InvalidJSON_ReturnsError(t *testing.T) { // Arrange - handler := note.NewCreateNoteHandler() + handler := newCreateNoteHandler() // Act _, err := handler.Handle(Fixture.TestContext, json.RawMessage(`{invalid json}`)) @@ -134,7 +143,7 @@ func TestCreateNoteHandler_InvalidJSON_ReturnsError(t *testing.T) { func TestCreateNoteHandler_NonExistentTemplateName_ReturnsError(t *testing.T) { // Arrange - handler := note.NewCreateNoteHandler() + handler := newCreateNoteHandler() params, _ := json.Marshal(map[string]any{ "title": "Ghost Note",