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",