handlers

package
v0.0.0-...-7f3acd9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Expect = AssertionHelpers{}

Functions

func AssertTaskDatesSet

func AssertTaskDatesSet(t *testing.T, task *models.Task)

AssertTaskDatesSet verifies that Entry and Modified timestamps are set

func AssertTaskHasUUID

func AssertTaskHasUUID(t *testing.T, task *models.Task)

AssertTaskHasUUID verifies that a task has a non-empty UUID

func CreateMockMovieSearchResults

func CreateMockMovieSearchResults() []services.Media

CreateMockMovieSearchResults creates sample movie search results for testing

func CreateMockTVSearchResults

func CreateMockTVSearchResults() []services.Media

CreateMockTVSearchResults creates sample TV search results for testing

func CreateTestMovieService

func CreateTestMovieService(mockFetcher *MockMediaFetcher) *services.MovieService

CreateTestMovieService creates a MovieService with mock dependencies for testing

func CreateTestTVService

func CreateTestTVService(mockFetcher *MockMediaFetcher) *services.TVService

CreateTestTVService creates a TVService with mock dependencies for testing

func ListMediaItems

func ListMediaItems[T any](
	ctx context.Context,
	status string,
	mediaType string,
	listAll func(ctx context.Context) ([]*T, error),
	listByStatus func(ctx context.Context, status string) ([]*T, error),
	printer MediaPrinter[T],
) error

ListMediaItems is a generic utility for listing media items with status filtering

func MockOpenLibraryResponse

func MockOpenLibraryResponse(books []MockBook) services.OpenLibrarySearchResponse

MockOpenLibraryResponse creates a mock OpenLibrary search response

func MockRottenTomatoesResponse

func MockRottenTomatoesResponse(movies []MockMedia) string

MockRottenTomatoesResponse creates a mock HTML response for Rotten Tomatoes

func ParseID

func ParseID(id string, itemType string) (int64, error)

ParseID converts a string ID to int64

func PrintSearchResults

func PrintSearchResults[T models.Model](results []*models.Model, formatter func(*models.Model, int)) error

PrintSearchResults displays search results with a type-specific formatter

func PromptUserChoice

func PromptUserChoice(reader io.Reader, maxChoices int) (int, error)

PromptUserChoice prompts the user to select from a list of results

func Reset

func Reset(ctx context.Context, args []string) error

Reset recreates the database and configuration (destructive)

func RunTUIScenarios

func RunTUIScenarios(t *testing.T, suite *ui.TUITestSuite, scenarios []TUITestScenario)

RunTUIScenarios executes a series of TUI test scenarios

func Setup

func Setup(ctx context.Context, args []string) error

Setup initializes the application database and configuration

func SetupHandlerTest

func SetupHandlerTest(t *testing.T) (string, func())

func Status

func Status(ctx context.Context, args []string, w io.Writer) error

Status shows the current application status

func TestBookInteractiveList

func TestBookInteractiveList(t *testing.T, handler *BookHandler, status string) error

TestBookInteractiveList tests book list browsing with TUI

func TestMovieInteractiveList

func TestMovieInteractiveList(t *testing.T, handler *MovieHandler, status string) error

TestMovieInteractiveList tests movie list browsing with TUI

func TestNoteInteractiveList

func TestNoteInteractiveList(t *testing.T, handler *NoteHandler, showArchived bool, tags []string) error

TestNoteInteractiveList tests note list browsing with TUI

func TestTVInteractiveList

func TestTVInteractiveList(t *testing.T, handler *TVHandler, status string) error

TestTVInteractiveList tests TV show list browsing with TUI

func TestTaskInteractiveList

func TestTaskInteractiveList(t *testing.T, handler *TaskHandler, showAll bool, status, priority, project string) error

TestTaskInteractiveList tests task list browsing with TUI

Types

type ArticleHandler

type ArticleHandler struct {
	// contains filtered or unexported fields
}

ArticleHandler handles all article-related commands

func NewArticleHandler

func NewArticleHandler() (*ArticleHandler, error)

NewArticleHandler creates a new article handler

func (*ArticleHandler) Add

func (h *ArticleHandler) Add(ctx context.Context, url string) error

Add handles adding an article from a URL

func (*ArticleHandler) Close

func (h *ArticleHandler) Close() error

Close cleans up resources

func (*ArticleHandler) Help

func (h *ArticleHandler) Help() error

Help shows supported domains (to complement default cobra/fang help)

func (*ArticleHandler) List

func (h *ArticleHandler) List(ctx context.Context, query string, author string, limit int) error

List handles listing articles with optional filtering

func (*ArticleHandler) Read

func (h *ArticleHandler) Read(ctx context.Context, id int64) error

Read displays an article's content with formatted markdown rendering

func (*ArticleHandler) Remove

func (h *ArticleHandler) Remove(ctx context.Context, id int64) error

Remove handles removing an article by ID

func (*ArticleHandler) View

func (h *ArticleHandler) View(ctx context.Context, id int64) error

View handles viewing an article by ID

type ArticleTestHelper

type ArticleTestHelper struct {
	*ArticleHandler
	// contains filtered or unexported fields
}

ArticleTestHelper wraps ArticleHandler with test-specific functionality

func NewArticleTestHelper

func NewArticleTestHelper(t *testing.T) *ArticleTestHelper

NewArticleTestHelper creates an ArticleHandler with isolated test database

func (*ArticleTestHelper) AddTestRule

func (ath *ArticleTestHelper) AddTestRule(domain string, rule *articles.ParsingRule)

AddTestRule adds a parsing rule to the handler's parser for testing

func (*ArticleTestHelper) CreateTestArticle

func (ath *ArticleTestHelper) CreateTestArticle(t *testing.T, url, title, author, date string) int64

CreateTestArticle creates a test article and returns its ID

type AssertionHelpers

type AssertionHelpers struct{}

AssertionHelpers provides test assertion utilities

func (AssertionHelpers) AssertArticleExists

func (ah AssertionHelpers) AssertArticleExists(t *testing.T, handler *ArticleTestHelper, id int64)

AssertArticleExists checks that an article exists in the database

func (AssertionHelpers) AssertArticleNotExists

func (ah AssertionHelpers) AssertArticleNotExists(t *testing.T, handler *ArticleTestHelper, id int64)

AssertArticleNotExists checks that an article does not exist in the database

func (AssertionHelpers) AssertError

func (ah AssertionHelpers) AssertError(t *testing.T, err error, expectedSubstring string, msg string)

AssertError checks that an error occurred and optionally contains expected text

func (AssertionHelpers) AssertNoError

func (ah AssertionHelpers) AssertNoError(t *testing.T, err error, msg string)

AssertNoError checks that no error occurred

func (AssertionHelpers) AssertNoteExists

func (ah AssertionHelpers) AssertNoteExists(t *testing.T, handler *HandlerTestHelper, id int64)

AssertNoteExists checks that a note exists in the database

func (AssertionHelpers) AssertNoteNotExists

func (ah AssertionHelpers) AssertNoteNotExists(t *testing.T, handler *HandlerTestHelper, id int64)

AssertNoteNotExists checks that a note does not exist in the database

type BookHandler

type BookHandler struct {
	// contains filtered or unexported fields
}

BookHandler handles all book-related commands

Implements MediaHandler interface for polymorphic media handling

func CreateBookHandler

func CreateBookHandler(t *testing.T) *BookHandler

CreateBookHandler creates a BookHandler for testing with automatic cleanup

func NewBookHandler

func NewBookHandler() (*BookHandler, error)

NewBookHandler creates a new book handler

func SetupBookHandlerWithInput

func SetupBookHandlerWithInput(t *testing.T, inputs ...string) (*BookHandler, func())

SetupHandlerWithInput creates a handler and sets up input simulation in one call

func (*BookHandler) Close

func (h *BookHandler) Close() error

Close cleans up resources

func (*BookHandler) List

func (h *BookHandler) List(ctx context.Context, status string) error

List lists all books with status filtering

func (*BookHandler) Remove

func (h *BookHandler) Remove(ctx context.Context, id string) error

Remove removes a book from the queue

func (*BookHandler) SearchAndAdd

func (h *BookHandler) SearchAndAdd(ctx context.Context, query string, interactive bool) error

SearchAndAdd searches for books and allows user to select and add to queue

func (*BookHandler) SetInputReader

func (h *BookHandler) SetInputReader(reader io.Reader)

SetInputReader sets the input reader

func (*BookHandler) UpdateProgress

func (h *BookHandler) UpdateProgress(ctx context.Context, id string, progress int) error

UpdateProgress updates a models.Book's reading progress percentage

func (*BookHandler) UpdateStatus

func (h *BookHandler) UpdateStatus(ctx context.Context, id, status string) error

UpdateStatus changes the status of a models.Book

type ConfigHandler

type ConfigHandler struct {
	// contains filtered or unexported fields
}

ConfigHandler handles store.Config-related operations

func NewConfigHandler

func NewConfigHandler() (*ConfigHandler, error)

NewConfigHandler creates a new ConfigHandler

func (*ConfigHandler) Get

func (h *ConfigHandler) Get(key string) error

Get displays one or all configuration values

func (*ConfigHandler) Path

func (h *ConfigHandler) Path() error

Path displays the configuration file path

func (*ConfigHandler) Reset

func (h *ConfigHandler) Reset() error

Reset resets the configuration to defaults

func (*ConfigHandler) Set

func (h *ConfigHandler) Set(key, value string) error

Set updates a configuration value

type DatabaseTestHelper

type DatabaseTestHelper struct {
	// contains filtered or unexported fields
}

DatabaseTestHelper provides database testing utilities

func NewDatabaseTestHelper

func NewDatabaseTestHelper(handler *HandlerTestHelper) *DatabaseTestHelper

NewDatabaseTestHelper creates a helper for database error testing

func (*DatabaseTestHelper) CloseDatabase

func (dth *DatabaseTestHelper) CloseDatabase()

CloseDatabase closes the database connection

func (*DatabaseTestHelper) CreateCorruptedDatabase

func (dth *DatabaseTestHelper) CreateCorruptedDatabase(t *testing.T)

CreateCorruptedDatabase creates a new database with corrupted schema

func (*DatabaseTestHelper) DropNotesTable

func (dth *DatabaseTestHelper) DropNotesTable()

DropNotesTable drops the notes table to simulate database errors

func (*DatabaseTestHelper) RestoreDatabase

func (dth *DatabaseTestHelper) RestoreDatabase(t *testing.T)

RestoreDatabase restores the original database connection

type EnvironmentTestHelper

type EnvironmentTestHelper struct {
	// contains filtered or unexported fields
}

EnvironmentTestHelper provides environment manipulation utilities for testing

func NewEnvironmentTestHelper

func NewEnvironmentTestHelper() *EnvironmentTestHelper

NewEnvironmentTestHelper creates a new environment test helper

func (*EnvironmentTestHelper) CreateTestDir

func (eth *EnvironmentTestHelper) CreateTestDir(t *testing.T) (string, error)

CreateTestDir creates a temporary test directory and sets up environment

func (*EnvironmentTestHelper) RestoreEnv

func (eth *EnvironmentTestHelper) RestoreEnv()

RestoreEnv restores all modified environment variables

func (*EnvironmentTestHelper) SetEnv

func (eth *EnvironmentTestHelper) SetEnv(key, value string)

SetEnv sets an environment variable and remembers the original value

func (*EnvironmentTestHelper) UnsetEnv

func (eth *EnvironmentTestHelper) UnsetEnv(key string)

UnsetEnv unsets an environment variable and remembers the original value

type HTTPMockServer

type HTTPMockServer struct {
	// contains filtered or unexported fields
}

HTTPMockServer provides utilities for mocking HTTP services in tests

func EmptyResponseMockServer

func EmptyResponseMockServer() *HTTPMockServer

EmptyResponseMockServer creates a mock server that returns empty responses

func HTTPErrorMockServer

func HTTPErrorMockServer(statusCode int, message string) *HTTPMockServer

HTTPErrorMockServer creates a mock server that returns HTTP errors

func InvalidJSONMockServer

func InvalidJSONMockServer() *HTTPMockServer

InvalidJSONMockServer creates a mock server that returns malformed JSON

func JSONMockServer

func JSONMockServer(response any) *HTTPMockServer

JSONMockServer creates a mock server that returns JSON responses

func NewMockServer

func NewMockServer() *HTTPMockServer

NewMockServer creates a new mock HTTP server

func TimeoutMockServer

func TimeoutMockServer(delay time.Duration) *HTTPMockServer

TimeoutMockServer creates a mock server that simulates timeouts

func (*HTTPMockServer) Close

func (m *HTTPMockServer) Close()

Close closes the mock server

func (*HTTPMockServer) GetLastRequest

func (m *HTTPMockServer) GetLastRequest() *http.Request

GetLastRequest returns the last recorded HTTP request

func (*HTTPMockServer) GetRequests

func (m *HTTPMockServer) GetRequests() []*http.Request

GetRequests returns all recorded HTTP requests

func (*HTTPMockServer) URL

func (m *HTTPMockServer) URL() string

URL returns the mock server URL

func (*HTTPMockServer) WithHandler

func (m *HTTPMockServer) WithHandler(handler http.HandlerFunc) *HTTPMockServer

WithHandler sets up the mock server with a custom handler

type HandlerTestHelper

type HandlerTestHelper struct {
	*NoteHandler
	// contains filtered or unexported fields
}

HandlerTestHelper wraps NoteHandler with test-specific functionality

func NewHandlerTestHelper

func NewHandlerTestHelper(t *testing.T) *HandlerTestHelper

NewHandlerTestHelper creates a NoteHandler with isolated test database

func (*HandlerTestHelper) CreateTestFile

func (th *HandlerTestHelper) CreateTestFile(t *testing.T, filename, content string) string

CreateTestFile creates a temporary markdown file with content

func (*HandlerTestHelper) CreateTestNote

func (th *HandlerTestHelper) CreateTestNote(t *testing.T, title, content string, tags []string) int64

CreateTestNote creates a test note and returns its ID

type InputSimulator

type InputSimulator struct {
	// contains filtered or unexported fields
}

InputSimulator provides controlled input simulation for testing fmt.Scanf interactions It implements io.Reader to provide predictable input sequences for interactive components

func MenuCancel() *InputSimulator

MenuCancel creates input simulator for cancelling menu selection

func MenuSelection(choice int) *InputSimulator

MenuSelection creates input simulator for menu selection scenarios

func MenuSequence(choices ...int) *InputSimulator

MenuSequence creates input simulator for multiple menu interactions

func NewInputSimulator

func NewInputSimulator(inputs ...string) *InputSimulator

NewInputSimulator creates a new input simulator with the given input sequence

func (*InputSimulator) AddInputs

func (is *InputSimulator) AddInputs(inputs ...string)

AddInputs appends new inputs to the sequence

func (*InputSimulator) HasMoreInputs

func (is *InputSimulator) HasMoreInputs() bool

HasMoreInputs returns true if there are more inputs available

func (*InputSimulator) Read

func (is *InputSimulator) Read(p []byte) (n int, err error)

Read implements io.Reader interface for fmt.Scanf compatibility

func (*InputSimulator) Reset

func (is *InputSimulator) Reset()

Reset resets the simulator to the beginning of the input sequence

type InteractiveTUIHelper

type InteractiveTUIHelper struct {
	// contains filtered or unexported fields
}

InteractiveTUIHelper bridges handler testing with TUI testing capabilities

func NewInteractiveTUIHelper

func NewInteractiveTUIHelper(t *testing.T, handler TUICapableHandler) *InteractiveTUIHelper

NewInteractiveTUIHelper creates a helper for testing handler TUI interactions

func (*InteractiveTUIHelper) StartTUITest

func (ith *InteractiveTUIHelper) StartTUITest(ctx context.Context) (*ui.TUITestSuite, error)

StartTUITest initializes and starts a TUI test session

func (*InteractiveTUIHelper) TestInteractiveList

func (ith *InteractiveTUIHelper) TestInteractiveList(ctx context.Context, testFunc func(*ui.TUITestSuite) error) error

TestInteractiveList tests interactive list browsing behavior

func (*InteractiveTUIHelper) TestInteractiveNavigation

func (ith *InteractiveTUIHelper) TestInteractiveNavigation(ctx context.Context, keySequence []tea.KeyType) error

TestInteractiveNavigation tests keyboard navigation patterns

func (*InteractiveTUIHelper) TestInteractiveSelection

func (ith *InteractiveTUIHelper) TestInteractiveSelection(ctx context.Context, selected int, action tea.KeyType) error

TestInteractiveSelection tests item selection and actions

func (*InteractiveTUIHelper) WithMockData

func (ith *InteractiveTUIHelper) WithMockData(data any) *InteractiveTUIHelper

WithMockData configures mock data for the TUI test

func (*InteractiveTUIHelper) WithSize

func (ith *InteractiveTUIHelper) WithSize(width, height int) *InteractiveTUIHelper

WithSize configures the TUI test dimensions

type InteractiveTestHelper

type InteractiveTestHelper struct {
	Stdin io.Reader
	// contains filtered or unexported fields
}

InteractiveTestHelper provides utilities for testing interactive handler components

func NewInteractiveTestHelper

func NewInteractiveTestHelper() *InteractiveTestHelper

NewInteractiveTestHelper creates a helper for testing interactive components

func (*InteractiveTestHelper) GetSimulator

func (ith *InteractiveTestHelper) GetSimulator() *InputSimulator

GetSimulator returns the current input simulator

func (*InteractiveTestHelper) SimulateCancel

func (ith *InteractiveTestHelper) SimulateCancel() *InputSimulator

SimulateCancel sets up input simulation for cancellation

func (*InteractiveTestHelper) SimulateInput

func (ith *InteractiveTestHelper) SimulateInput(inputs ...string) *InputSimulator

SimulateInput sets up input simulation for the test

func (*InteractiveTestHelper) SimulateMenuChoice

func (ith *InteractiveTestHelper) SimulateMenuChoice(choice int) *InputSimulator

SimulateMenuChoice sets up input simulation for menu selection

type Listable

type Listable interface {
	List(ctx context.Context, status string) error
}

Listable defines list behavior for media handlers

type MarkdownRenderer

type MarkdownRenderer interface {
	Render(string) (string, error)
}

type MediaHandler

type MediaHandler interface {
	// SearchAndAdd searches for media and allows user to select and add to queue
	SearchAndAdd(ctx context.Context, query string, interactive bool) error
	// List lists all media items with optional status filtering
	List(ctx context.Context, status string) error
	// UpdateStatus changes the status of a media item
	UpdateStatus(ctx context.Context, id, status string) error
	// Remove removes a media item from the queue
	Remove(ctx context.Context, id string) error
	// SetInputReader sets the input reader for interactive prompts
	SetInputReader(reader io.Reader)
	// Close cleans up resources
	Close() error
}

MediaHandler defines common operations for media handlers

This interface captures the shared behavior across media handlers for polymorphic handling of different media types.

type MediaPrinter

type MediaPrinter[T any] func(item *T)

MediaPrinter defines how to format a media item for display

type MockBook

type MockBook struct {
	Key      string
	Title    string
	Authors  []string
	Year     int
	Editions int
	CoverID  int
}

MockBook represents a book for testing

type MockEditor

type MockEditor struct {
	// contains filtered or unexported fields
}

MockEditor provides a mock editor function for testing

func NewMockEditor

func NewMockEditor() *MockEditor

NewMockEditor creates a mock editor with default success behavior

func (*MockEditor) GetEditorFunc

func (me *MockEditor) GetEditorFunc() editorFunc

GetEditorFunc returns the editor function for use with NoteHandler

func (*MockEditor) WithContent

func (me *MockEditor) WithContent(content string) *MockEditor

WithContent configures the content the mock editor will write

func (*MockEditor) WithFailure

func (me *MockEditor) WithFailure(msg string) *MockEditor

WithFailure configures the mock editor to fail

func (*MockEditor) WithFileDeleted

func (me *MockEditor) WithFileDeleted() *MockEditor

WithFileDeleted configures the mock editor to delete the temp file

func (*MockEditor) WithReadOnly

func (me *MockEditor) WithReadOnly() *MockEditor

WithReadOnly configures the mock editor to make the file read-only

type MockMedia

type MockMedia struct {
	Title string
	Link  string
	Score string
	Type  string
}

MockMedia represents media for testing

type MockMediaFetcher

type MockMediaFetcher struct {
	SearchResults []services.Media
	HTMLContent   string
	MovieData     *services.Movie
	TVSeriesData  *services.TVSeries
	ShouldError   bool
	ErrorMessage  string
}

MockMediaFetcher provides a test implementation of Fetchable and Searchable interfaces

func (*MockMediaFetcher) MakeRequest

func (m *MockMediaFetcher) MakeRequest(url string) (string, error)

MakeRequest implements the Fetchable interface for testing

func (*MockMediaFetcher) MovieRequest

func (m *MockMediaFetcher) MovieRequest(url string) (*services.Movie, error)

MovieRequest implements the Fetchable interface for testing

func (*MockMediaFetcher) Search

func (m *MockMediaFetcher) Search(query string) ([]services.Media, error)

Search implements the Searchable interface for testing

func (*MockMediaFetcher) TVRequest

func (m *MockMediaFetcher) TVRequest(url string) (*services.TVSeries, error)

TVRequest implements the Fetchable interface for testing

type MovieHandler

type MovieHandler struct {
	// contains filtered or unexported fields
}

MovieHandler handles all movie-related commands

func CreateMovieHandler

func CreateMovieHandler(t *testing.T) *MovieHandler

CreateMovieHandler creates a MovieHandler for testing with automatic cleanup

func NewMovieHandler

func NewMovieHandler() (*MovieHandler, error)

NewMovieHandler creates a new movie handler

func SetupMovieHandlerWithInput

func SetupMovieHandlerWithInput(t *testing.T, inputs ...string) (*MovieHandler, func())

SetupMovieHandlerWithInput creates a movie handler and sets up input simulation

func (*MovieHandler) Close

func (h *MovieHandler) Close() error

Close cleans up resources

func (*MovieHandler) List

func (h *MovieHandler) List(ctx context.Context, status string) error

List lists all movies in the queue with status filtering

func (*MovieHandler) MarkWatched

func (h *MovieHandler) MarkWatched(ctx context.Context, id string) error

MarkWatched marks a movie as watched

func (*MovieHandler) Remove

func (h *MovieHandler) Remove(ctx context.Context, id string) error

Remove removes a movie from the queue

func (*MovieHandler) SearchAndAdd

func (h *MovieHandler) SearchAndAdd(ctx context.Context, query string, interactive bool) error

SearchAndAdd searches for movies and allows user to select and add to queue

func (*MovieHandler) SetInputReader

func (h *MovieHandler) SetInputReader(reader io.Reader)

SetInputReader sets the input reader

func (*MovieHandler) UpdateStatus

func (h *MovieHandler) UpdateStatus(ctx context.Context, id, status string) error

UpdateStatus changes the status of a movie

func (*MovieHandler) View

func (h *MovieHandler) View(ctx context.Context, movieID int64) error

View displays detailed information about a specific movie

type NoteHandler

type NoteHandler struct {
	// contains filtered or unexported fields
}

NoteHandler handles all note-related commands

func NewNoteHandler

func NewNoteHandler() (*NoteHandler, error)

NewNoteHandler creates a new note handler

func (*NoteHandler) Close

func (h *NoteHandler) Close() error

Close cleans up resources

func (*NoteHandler) Create

func (h *NoteHandler) Create(ctx context.Context, title string, content string, filePath string, interactive bool) error

Create handles note creation with optional title, content, and file path

func (*NoteHandler) CreateWithOptions

func (h *NoteHandler) CreateWithOptions(ctx context.Context, title string, content string, filePath string, interactive bool, promptEditor bool) error

CreateWithOptions handles note creation with additional options

func (*NoteHandler) Delete

func (h *NoteHandler) Delete(ctx context.Context, id int64) error

Delete permanently removes a note and its metadata

func (*NoteHandler) Edit

func (h *NoteHandler) Edit(ctx context.Context, id int64) error

Edit handles note editing by ID

func (*NoteHandler) List

func (h *NoteHandler) List(ctx context.Context, static, showArchived bool, tags []string) error

List opens either an interactive TUI browser for navigating and viewing notes or a static list

func (*NoteHandler) View

func (h *NoteHandler) View(ctx context.Context, id int64) error

View displays a note with formatted markdown content

type ParsedTaskData

type ParsedTaskData struct {
	Description string
	Project     string
	Context     string
	Tags        []string
	Due         string
	Recur       string
	Until       string
	ParentUUID  string
	DependsOn   []string
}

ParsedTaskData holds extracted metadata from a task description

type Removable

type Removable interface {
	Remove(ctx context.Context, id string) error
}

Removable defines remove behavior for media handlers

type Searchable

type Searchable interface {
	SearchAndAdd(ctx context.Context, query string, interactive bool) error
}

Searchable defines search behavior for media handlers

type SeedHandler

type SeedHandler struct {
	// contains filtered or unexported fields
}

SeedHandler handles database seeding operations

func NewSeedHandler

func NewSeedHandler() (*SeedHandler, error)

NewSeedHandler creates a new seed handler

func (*SeedHandler) Close

func (h *SeedHandler) Close() error

Close cleans up resources

func (*SeedHandler) Seed

func (h *SeedHandler) Seed(ctx context.Context, force bool) error

Seed populates the database with test data for demonstration and testing

type ServiceTestHelper

type ServiceTestHelper struct {
	// contains filtered or unexported fields
}

ServiceTestHelper provides utilities for testing services with HTTP mocks

func NewServiceTestHelper

func NewServiceTestHelper() *ServiceTestHelper

NewServiceTestHelper creates a new service test helper

func (*ServiceTestHelper) AddMockServer

func (sth *ServiceTestHelper) AddMockServer(server *HTTPMockServer) string

AddMockServer adds a mock server and returns its URL

func (*ServiceTestHelper) AssertRequestMade

func (sth *ServiceTestHelper) AssertRequestMade(t *testing.T, server *HTTPMockServer, expectedPath string)

AssertRequestMade verifies that a request was made to the mock server

func (*ServiceTestHelper) Cleanup

func (sth *ServiceTestHelper) Cleanup()

Cleanup closes all mock servers

type StatusUpdatable

type StatusUpdatable interface {
	UpdateStatus(ctx context.Context, id, status string) error
}

StatusUpdatable defines status update behavior for media handlers

type TUICapableHandler

type TUICapableHandler interface {
	GetTUIModel(ctx context.Context, opts TUITestOptions) (tea.Model, error)
	SetTUITestMode(enabled bool)
}

TUICapableHandler interface for handlers that can expose TUI models for testing

type TUITestOptions

type TUITestOptions struct {
	Width    int
	Height   int
	Static   bool
	Output   io.Writer
	Input    io.Reader
	MockData any
}

TUITestOptions configures TUI testing behavior for handlers

type TUITestScenario

type TUITestScenario struct {
	Name         string
	KeySequence  []tea.KeyType
	ExpectedView string
	Timeout      time.Duration
}

TUITestScenario defines a common test scenario for interactive components

func CommonTUIScenarios

func CommonTUIScenarios() []TUITestScenario

CommonTUIScenarios returns standard TUI testing scenarios

type TVHandler

type TVHandler struct {
	// contains filtered or unexported fields
}

TVHandler handles all TV show-related commands

Implements MediaHandler interface for polymorphic media handling

func CreateTVHandler

func CreateTVHandler(t *testing.T) *TVHandler

CreateTVHandler creates a TVHandler for testing with automatic cleanup

func NewTVHandler

func NewTVHandler() (*TVHandler, error)

NewTVHandler creates a new TV handler

func SetupTVHandlerWithInput

func SetupTVHandlerWithInput(t *testing.T, inputs ...string) (*TVHandler, func())

SetupTVHandlerWithInput creates a TV handler and sets up input simulation

func (*TVHandler) Close

func (h *TVHandler) Close() error

Close cleans up resources

func (*TVHandler) List

func (h *TVHandler) List(ctx context.Context, status string) error

List TV shows with status filtering

func (*TVHandler) MarkTVShowWatching

func (h *TVHandler) MarkTVShowWatching(ctx context.Context, id string) error

MarkTVShowWatching marks a TV show as currently watching

func (*TVHandler) MarkWatched

func (h *TVHandler) MarkWatched(ctx context.Context, id string) error

MarkWatched marks a TV show as watched

func (*TVHandler) MarkWatching

func (h *TVHandler) MarkWatching(ctx context.Context, id string) error

MarkWatching marks a TV show as currently watching

func (*TVHandler) Remove

func (h *TVHandler) Remove(ctx context.Context, id string) error

Remove removes a TV show from the queue

func (*TVHandler) SearchAndAdd

func (h *TVHandler) SearchAndAdd(ctx context.Context, query string, interactive bool) error

SearchAndAdd searches for TV shows and allows user to select and add to queue

func (*TVHandler) SetInputReader

func (h *TVHandler) SetInputReader(reader io.Reader)

SetInputReader sets the input reader

func (*TVHandler) UpdateStatus

func (h *TVHandler) UpdateStatus(ctx context.Context, id, status string) error

UpdateStatus changes the status of a TV show

func (*TVHandler) UpdateTVShowStatus

func (h *TVHandler) UpdateTVShowStatus(ctx context.Context, id, status string) error

UpdateTVShowStatus changes the status of a TV show

func (*TVHandler) View

func (h *TVHandler) View(ctx context.Context, id string) error

View displays detailed information about a specific TV show

type TaskHandler

type TaskHandler struct {
	// contains filtered or unexported fields
}

TaskHandler handles all task-related commands

func CreateTaskHandler

func CreateTaskHandler(t *testing.T) *TaskHandler

CreateTaskHandler creates a TaskHandler for testing with automatic cleanup

func NewTaskHandler

func NewTaskHandler() (*TaskHandler, error)

NewTaskHandler creates a new task handler

func (*TaskHandler) AddDep

func (h *TaskHandler) AddDep(ctx context.Context, taskID, dependsOnUUID string) error

AddDep adds a dependency to a task

func (*TaskHandler) BlockedByDep

func (h *TaskHandler) BlockedByDep(ctx context.Context, taskID string) error

BlockedByDep shows tasks that are blocked by the given task

func (*TaskHandler) ClearRecur

func (h *TaskHandler) ClearRecur(ctx context.Context, taskID string) error

ClearRecur clears the recurrence rule from a task

func (*TaskHandler) Close

func (h *TaskHandler) Close() error

Close cleans up resources

func (*TaskHandler) Create

func (h *TaskHandler) Create(ctx context.Context, description, priority, project, context, due, recur, until, parentUUID, dependsOn string, tags []string) error

Create creates a new task

func (*TaskHandler) Delete

func (h *TaskHandler) Delete(ctx context.Context, args []string) error

Delete deletes a task

func (*TaskHandler) Done

func (h *TaskHandler) Done(ctx context.Context, args []string) error

Done marks a task as completed

func (*TaskHandler) EditInteractive

func (h *TaskHandler) EditInteractive(ctx context.Context, taskID string) error

EditInteractive opens an interactive task editor with status picker and priority toggle

func (*TaskHandler) List

func (h *TaskHandler) List(ctx context.Context, static, showAll bool, status, priority, project, context string) error

List lists all tasks with optional filtering

func (*TaskHandler) ListContexts

func (h *TaskHandler) ListContexts(ctx context.Context, static bool, todoTxt ...bool) error

ListContexts lists all contexts with their task counts

func (*TaskHandler) ListDeps

func (h *TaskHandler) ListDeps(ctx context.Context, taskID string) error

ListDeps lists all dependencies for a task

func (*TaskHandler) ListProjects

func (h *TaskHandler) ListProjects(ctx context.Context, static bool, todoTxt ...bool) error

ListProjects lists all projects with their task counts

func (*TaskHandler) ListTags

func (h *TaskHandler) ListTags(ctx context.Context, static bool) error

ListTags lists all tags with their task counts

func (*TaskHandler) RemoveDep

func (h *TaskHandler) RemoveDep(ctx context.Context, taskID, dependsOnUUID string) error

RemoveDep removes a dependency from a task

func (*TaskHandler) SetRecur

func (h *TaskHandler) SetRecur(ctx context.Context, taskID, rule, until string) error

SetRecur sets the recurrence rule for a task

func (*TaskHandler) ShowRecur

func (h *TaskHandler) ShowRecur(ctx context.Context, taskID string) error

ShowRecur displays the recurrence details for a task

func (*TaskHandler) Start

func (h *TaskHandler) Start(ctx context.Context, taskID string, description string) error

Start starts time tracking for a task

func (*TaskHandler) Stop

func (h *TaskHandler) Stop(ctx context.Context, taskID string) error

Stop stops time tracking for a task

func (*TaskHandler) Timesheet

func (h *TaskHandler) Timesheet(ctx context.Context, days int, taskID string) error

Timesheet shows time tracking summary

func (*TaskHandler) Update

func (h *TaskHandler) Update(ctx context.Context, taskID, description, status, priority, project, context, due, recur, until, parentUUID string, addTags, removeTags []string, addDeps, removeDeps string) error

Update updates a task using parsed flag values

func (*TaskHandler) View

func (h *TaskHandler) View(ctx context.Context, args []string, format string, jsonOutput, noMetadata bool) error

View displays a single task

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL