Documentation
¶
Index ¶
- func AssertFileExists(t *testing.T, path string)
- func AssertFileNotExists(t *testing.T, path string)
- func CreateInvalidTorrent(t *testing.T, dir, name string) string
- func CreateMagnetLink(t *testing.T, dir, name string) string
- func CreateRealTestTorrent(t *testing.T, dir, name string) string
- func CreateTestDataFile(t *testing.T, dir, name string, size int64) string
- func CreateTestTorrent(t *testing.T, dir, name string) string
- func MockHTTPServer(t *testing.T, responses map[string]string) *httptest.Server
- func MockYTDLPServer(t *testing.T) *httptest.Server
- func TempDir(t *testing.T) string
- func TestConfig(tempDir string) *config.Config
- func TestDatabase(t *testing.T) database.Database
- func WaitForCondition(t *testing.T, condition func() bool, timeout time.Duration, message string)
- type DatabaseStub
- func (*DatabaseStub) AddMovie(_ context.Context, _ string, _ int64, _, _ []string, _ int) (uint, error)
- func (*DatabaseStub) AssignTemporaryPassword(_ context.Context, _ string, _ int64) error
- func (*DatabaseStub) ExtendTemporaryUser(_ context.Context, _ int64, _ time.Time) error
- func (*DatabaseStub) GenerateTemporaryPassword(_ context.Context, _ time.Duration) (string, error)
- func (*DatabaseStub) GetFilesByMovieID(_ context.Context, _ uint) ([]database.MovieFile, error)
- func (*DatabaseStub) GetIncompleteQBittorrentDownloads(_ context.Context) ([]database.Movie, error)
- func (*DatabaseStub) GetMovieByID(_ context.Context, _ uint) (database.Movie, error)
- func (*DatabaseStub) GetMovieList(_ context.Context) ([]database.Movie, error)
- func (*DatabaseStub) GetTempFilesByMovieID(_ context.Context, _ uint) ([]database.MovieFile, error)
- func (*DatabaseStub) GetUserByChatID(_ context.Context, _ int64) (database.User, error)
- func (*DatabaseStub) GetUserRole(_ context.Context, _ int64) (database.UserRole, error)
- func (*DatabaseStub) Init(_ *tmsconfig.Config) error
- func (*DatabaseStub) IsUserAccessAllowed(_ context.Context, _ int64) (allowed bool, role database.UserRole, err error)
- func (*DatabaseStub) Login(_ context.Context, _ string, _ int64, _ string, _ *tmsconfig.Config) (bool, error)
- func (*DatabaseStub) MovieExistsFiles(_ context.Context, _ []string) (bool, error)
- func (*DatabaseStub) MovieExistsId(_ context.Context, _ uint) (bool, error)
- func (*DatabaseStub) MovieExistsUploadedFile(_ context.Context, _ string) (bool, error)
- func (*DatabaseStub) RemoveFilesByMovieID(_ context.Context, _ uint) error
- func (*DatabaseStub) RemoveMovie(_ context.Context, _ uint) error
- func (*DatabaseStub) RemoveTempFilesByMovieID(_ context.Context, _ uint) error
- func (*DatabaseStub) SetLoaded(_ context.Context, _ uint) error
- func (*DatabaseStub) SetQBittorrentHash(_ context.Context, _ uint, _ string) error
- func (*DatabaseStub) SetTvCompatibility(_ context.Context, _ uint, _ string) error
- func (*DatabaseStub) UpdateConversionPercentage(_ context.Context, _ uint, _ int) error
- func (*DatabaseStub) UpdateConversionStatus(_ context.Context, _ uint, _ string) error
- func (*DatabaseStub) UpdateDownloadedPercentage(_ context.Context, _ uint, _ int) error
- func (*DatabaseStub) UpdateEpisodesProgress(_ context.Context, _ uint, _ int) error
- func (*DatabaseStub) UpdateMovieName(_ context.Context, _ uint, _ string) error
- type MockBot
- func (*MockBot) AnswerCallbackQuery(_ tgbotapi.CallbackConfig)
- func (m *MockBot) ClearMessages()
- func (*MockBot) DeleteMessage(_ int64, _ int) error
- func (*MockBot) DownloadFile(_, _ string) error
- func (*MockBot) EditMessageTextAndMarkup(_ int64, _ int, _ string, _ tgbotapi.InlineKeyboardMarkup) error
- func (m *MockBot) GetLastDocument() *MockDocument
- func (m *MockBot) GetLastMessage() *MockMessage
- func (*MockBot) SaveFile(_ string, _ []byte) error
- func (m *MockBot) SendDocument(chatID int64, fileName string, data []byte) error
- func (m *MockBot) SendMessage(chatID int64, text string, keyboard any)
- func (*MockBot) SendMessageReturningID(_ int64, _ string, _ any) (int, error)
- type MockDocument
- type MockDownloader
- func (m *MockDownloader) GetFileSize() (int64, error)
- func (m *MockDownloader) GetFiles() (mainFiles, tempFiles []string, err error)
- func (m *MockDownloader) GetTitle() (string, error)
- func (m *MockDownloader) StartDownload(ctx context.Context) (progressChan chan float64, errChan chan error, episodesChan <-chan int, ...)
- func (m *MockDownloader) StopDownload() error
- func (m *MockDownloader) StoppedManually() bool
- func (m *MockDownloader) TotalEpisodes() int
- type MockMessage
- type TestSQLiteDatabase
- func (t *TestSQLiteDatabase) AddMovie(ctx context.Context, name string, fileSize int64, ...) (uint, error)
- func (*TestSQLiteDatabase) AssignTemporaryPassword(_ context.Context, _ string, _ int64) error
- func (*TestSQLiteDatabase) ExtendTemporaryUser(_ context.Context, _ int64, _ time.Time) error
- func (*TestSQLiteDatabase) GenerateTemporaryPassword(_ context.Context, _ time.Duration) (string, error)
- func (*TestSQLiteDatabase) GetFilesByMovieID(_ context.Context, _ uint) ([]database.MovieFile, error)
- func (*TestSQLiteDatabase) GetIncompleteQBittorrentDownloads(_ context.Context) ([]database.Movie, error)
- func (*TestSQLiteDatabase) GetMovieByID(_ context.Context, _ uint) (database.Movie, error)
- func (*TestSQLiteDatabase) GetMovieList(_ context.Context) ([]database.Movie, error)
- func (*TestSQLiteDatabase) GetTempFilesByMovieID(_ context.Context, _ uint) ([]database.MovieFile, error)
- func (*TestSQLiteDatabase) GetUserByChatID(_ context.Context, _ int64) (database.User, error)
- func (*TestSQLiteDatabase) GetUserRole(_ context.Context, _ int64) (database.UserRole, error)
- func (*TestSQLiteDatabase) Init(_ *config.Config) error
- func (*TestSQLiteDatabase) IsUserAccessAllowed(_ context.Context, _ int64) (isAllowed bool, userRole database.UserRole, err error)
- func (*TestSQLiteDatabase) Login(_ context.Context, _ string, _ int64, _ string, _ *config.Config) (bool, error)
- func (*TestSQLiteDatabase) MovieExistsFiles(_ context.Context, _ []string) (bool, error)
- func (*TestSQLiteDatabase) MovieExistsId(_ context.Context, _ uint) (bool, error)
- func (*TestSQLiteDatabase) MovieExistsUploadedFile(_ context.Context, _ string) (bool, error)
- func (*TestSQLiteDatabase) RemoveFilesByMovieID(_ context.Context, _ uint) error
- func (*TestSQLiteDatabase) RemoveMovie(_ context.Context, _ uint) error
- func (*TestSQLiteDatabase) RemoveTempFilesByMovieID(_ context.Context, _ uint) error
- func (*TestSQLiteDatabase) SetLoaded(_ context.Context, _ uint) error
- func (*TestSQLiteDatabase) SetQBittorrentHash(_ context.Context, _ uint, _ string) error
- func (*TestSQLiteDatabase) SetTvCompatibility(_ context.Context, _ uint, _ string) error
- func (*TestSQLiteDatabase) UpdateConversionPercentage(_ context.Context, _ uint, _ int) error
- func (*TestSQLiteDatabase) UpdateConversionStatus(_ context.Context, _ uint, _ string) error
- func (*TestSQLiteDatabase) UpdateDownloadedPercentage(_ context.Context, _ uint, _ int) error
- func (*TestSQLiteDatabase) UpdateEpisodesProgress(_ context.Context, _ uint, _ int) error
- func (t *TestSQLiteDatabase) UpdateMovieName(ctx context.Context, movieID uint, name string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFileExists ¶
AssertFileExists checks if a file exists
func AssertFileNotExists ¶
AssertFileNotExists checks if a file doesn't exist
func CreateInvalidTorrent ¶
CreateInvalidTorrent creates an invalid torrent file (HTML) for testing
func CreateMagnetLink ¶
CreateMagnetLink creates a magnet link file for testing
func CreateRealTestTorrent ¶
CreateRealTestTorrent creates a more realistic torrent file using bencode library
func CreateTestDataFile ¶
CreateTestDataFile creates a test data file with specified size
func CreateTestTorrent ¶
CreateTestTorrent creates a minimal valid torrent file for testing
func MockHTTPServer ¶
MockHTTPServer creates a mock HTTP server for testing
func MockYTDLPServer ¶
MockYTDLPServer creates a mock server that responds like a video hosting service
func TestConfig ¶
TestConfig creates a configuration suitable for testing
func TestDatabase ¶
TestDatabase creates an in-memory SQLite database for testing
Types ¶
type DatabaseStub ¶ added in v1.4.3
type DatabaseStub struct{}
DatabaseStub implements database.Database with no-op methods. Embed it in test-specific mocks and override only the methods you need.
func (*DatabaseStub) AssignTemporaryPassword ¶ added in v1.4.3
func (*DatabaseStub) ExtendTemporaryUser ¶ added in v1.4.3
func (*DatabaseStub) GenerateTemporaryPassword ¶ added in v1.4.3
func (*DatabaseStub) GetFilesByMovieID ¶ added in v1.4.3
func (*DatabaseStub) GetIncompleteQBittorrentDownloads ¶ added in v1.6.0
func (*DatabaseStub) GetMovieByID ¶ added in v1.4.3
func (*DatabaseStub) GetMovieList ¶ added in v1.4.3
func (*DatabaseStub) GetTempFilesByMovieID ¶ added in v1.4.3
func (*DatabaseStub) GetUserByChatID ¶ added in v1.4.3
func (*DatabaseStub) GetUserRole ¶ added in v1.4.3
func (*DatabaseStub) IsUserAccessAllowed ¶ added in v1.4.3
func (*DatabaseStub) MovieExistsFiles ¶ added in v1.4.3
func (*DatabaseStub) MovieExistsId ¶ added in v1.4.3
func (*DatabaseStub) MovieExistsUploadedFile ¶ added in v1.4.3
func (*DatabaseStub) RemoveFilesByMovieID ¶ added in v1.4.3
func (*DatabaseStub) RemoveFilesByMovieID(_ context.Context, _ uint) error
func (*DatabaseStub) RemoveMovie ¶ added in v1.4.3
func (*DatabaseStub) RemoveMovie(_ context.Context, _ uint) error
func (*DatabaseStub) RemoveTempFilesByMovieID ¶ added in v1.4.3
func (*DatabaseStub) RemoveTempFilesByMovieID(_ context.Context, _ uint) error
func (*DatabaseStub) SetLoaded ¶ added in v1.4.3
func (*DatabaseStub) SetLoaded(_ context.Context, _ uint) error
func (*DatabaseStub) SetQBittorrentHash ¶ added in v1.6.0
func (*DatabaseStub) SetTvCompatibility ¶ added in v1.4.3
func (*DatabaseStub) UpdateConversionPercentage ¶ added in v1.4.3
func (*DatabaseStub) UpdateConversionStatus ¶ added in v1.4.3
func (*DatabaseStub) UpdateDownloadedPercentage ¶ added in v1.4.3
func (*DatabaseStub) UpdateEpisodesProgress ¶ added in v1.4.3
func (*DatabaseStub) UpdateMovieName ¶ added in v1.5.5
type MockBot ¶ added in v1.4.3
type MockBot struct {
SentMessages []MockMessage
SentDocuments []MockDocument
// SendDocumentError, if set, is returned by SendDocument.
SendDocumentError error
}
MockBot implements bot.Service for testing. SentMessages collects every message sent via SendMessage. SentDocuments collects every document sent via SendDocument.
func (*MockBot) AnswerCallbackQuery ¶ added in v1.4.3
func (*MockBot) AnswerCallbackQuery(_ tgbotapi.CallbackConfig)
func (*MockBot) ClearMessages ¶ added in v1.4.3
func (m *MockBot) ClearMessages()
ClearMessages resets the captured messages.
func (*MockBot) DownloadFile ¶ added in v1.4.3
func (*MockBot) EditMessageTextAndMarkup ¶ added in v1.4.3
func (*MockBot) GetLastDocument ¶ added in v1.4.5
func (m *MockBot) GetLastDocument() *MockDocument
GetLastDocument returns the most recently sent document, or nil if none.
func (*MockBot) GetLastMessage ¶ added in v1.4.3
func (m *MockBot) GetLastMessage() *MockMessage
GetLastMessage returns the most recently sent message, or nil if none.
func (*MockBot) SendDocument ¶ added in v1.4.5
func (*MockBot) SendMessage ¶ added in v1.4.3
type MockDocument ¶ added in v1.4.5
MockDocument captures a single document sent by MockBot.
type MockDownloader ¶ added in v1.3.4
type MockDownloader struct {
ShouldBlock bool
ShouldError bool
ErrorMessage string
Title string
Files []string
TempFiles []string
FileSize int64
// EpisodesChan if set is returned from StartDownload; test can send completed episode counts (e.g. 1 for first_episode_ready).
EpisodesChan chan int
// TotalEps overrides TotalEpisodes() return value when > 0.
TotalEps int
// contains filtered or unexported fields
}
MockDownloader implements the downloader interface for testing. It provides methods for controlling download behavior in tests.
func (*MockDownloader) GetFileSize ¶ added in v1.3.4
func (m *MockDownloader) GetFileSize() (int64, error)
func (*MockDownloader) GetFiles ¶ added in v1.3.4
func (m *MockDownloader) GetFiles() (mainFiles, tempFiles []string, err error)
func (*MockDownloader) GetTitle ¶ added in v1.3.4
func (m *MockDownloader) GetTitle() (string, error)
func (*MockDownloader) StartDownload ¶ added in v1.3.4
func (*MockDownloader) StopDownload ¶ added in v1.3.4
func (m *MockDownloader) StopDownload() error
func (*MockDownloader) StoppedManually ¶ added in v1.3.4
func (m *MockDownloader) StoppedManually() bool
func (*MockDownloader) TotalEpisodes ¶ added in v1.4.0
func (m *MockDownloader) TotalEpisodes() int
type MockMessage ¶ added in v1.4.3
MockMessage captures a single message sent by MockBot.
type TestSQLiteDatabase ¶
type TestSQLiteDatabase struct {
// contains filtered or unexported fields
}
TestSQLiteDatabase is a test-specific implementation
func (*TestSQLiteDatabase) AddMovie ¶
func (t *TestSQLiteDatabase) AddMovie( ctx context.Context, name string, fileSize int64, mainFiles, tempFiles []string, totalEpisodes int, ) (uint, error)
Implement all database interface methods by delegating to the real implementation
func (*TestSQLiteDatabase) AssignTemporaryPassword ¶
func (*TestSQLiteDatabase) ExtendTemporaryUser ¶
func (*TestSQLiteDatabase) GenerateTemporaryPassword ¶
func (*TestSQLiteDatabase) GetFilesByMovieID ¶
func (*TestSQLiteDatabase) GetIncompleteQBittorrentDownloads ¶ added in v1.6.0
func (*TestSQLiteDatabase) GetMovieByID ¶
func (*TestSQLiteDatabase) GetMovieList ¶
func (*TestSQLiteDatabase) GetTempFilesByMovieID ¶
func (*TestSQLiteDatabase) GetUserByChatID ¶
func (*TestSQLiteDatabase) GetUserRole ¶
func (*TestSQLiteDatabase) IsUserAccessAllowed ¶
func (*TestSQLiteDatabase) MovieExistsFiles ¶
func (*TestSQLiteDatabase) MovieExistsId ¶
func (*TestSQLiteDatabase) MovieExistsUploadedFile ¶
func (*TestSQLiteDatabase) RemoveFilesByMovieID ¶
func (*TestSQLiteDatabase) RemoveFilesByMovieID(_ context.Context, _ uint) error
func (*TestSQLiteDatabase) RemoveMovie ¶
func (*TestSQLiteDatabase) RemoveMovie(_ context.Context, _ uint) error
Add other required methods...
func (*TestSQLiteDatabase) RemoveTempFilesByMovieID ¶
func (*TestSQLiteDatabase) RemoveTempFilesByMovieID(_ context.Context, _ uint) error
func (*TestSQLiteDatabase) SetLoaded ¶
func (*TestSQLiteDatabase) SetLoaded(_ context.Context, _ uint) error