tui

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

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

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OpenKdbxCmd            = openKdbxCmd
	SaveKdbxCmd            = saveKdbxCmd
	ClearStatusCmd         = clearStatusCmd
	StartSyncCmd           = startSyncCmd
	FetchServerMetadataCmd = fetchServerMetadataCmd
)

Экспортируем функции-команды для тестирования.

Functions

func CreateBasicTestDB

func CreateBasicTestDB() *gokeepasslib.Database

CreateBasicTestDB создает простую тестовую базу данных.

func DeepCopyEntry

func DeepCopyEntry(original gokeepasslib.Entry) gokeepasslib.Entry

DeepCopyEntry создает глубокую копию записи.

func FindEntryInDB

func FindEntryInDB(db *gokeepasslib.Database, uuid gokeepasslib.UUID) *gokeepasslib.Entry

FindEntryInDB ищет запись по UUID в базе данных.

func FindEntryInGroups

func FindEntryInGroups(groups []gokeepasslib.Group, uuid gokeepasslib.UUID) *gokeepasslib.Entry

FindEntryInGroups рекурсивно ищет запись по UUID.

func Start

func Start(kdbxPath string, debugMode bool, serverURL string)

Start запускает TUI приложение.

Types

type ClearStatusMsg

type ClearStatusMsg struct{}

ClearStatusMsg сообщение для очистки статусного сообщения.

type DBOpenedMsg

type DBOpenedMsg struct {
	DB *gokeepasslib.Database
}

DBOpenedMsg сообщение об успешном открытии базы данных.

type DBSaveErrorMsg

type DBSaveErrorMsg struct {
	Err error
}

DBSaveErrorMsg сообщение об ошибке сохранения базы данных.

type DBSavedMsg

type DBSavedMsg struct{}

DBSavedMsg сообщение об успешном сохранении базы данных.

type ErrMsg

type ErrMsg struct {
	Err error
}

ErrMsg сообщение об ошибке.

type LocalMetadataMsg

type LocalMetadataMsg struct {
	ModTime time.Time
	Found   bool
}

LocalMetadataMsg содержит метаданные локального файла.

type LoginError

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

func (LoginError) Error

func (e LoginError) Error() string

type LoginSuccessMsg

type LoginSuccessMsg struct {
	Token string
}

LoginSuccessMsg сообщение об успешном входе.

type MockResponse

type MockResponse struct {
	Success bool
	Token   string
	Error   error
}

MockResponse создает ответ для мока API клиента.

type RegisterError

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

func (RegisterError) Error

func (e RegisterError) Error() string

type RegisterSuccessMsg

type RegisterSuccessMsg struct{}

RegisterSuccessMsg сообщение об успешной регистрации.

type ScreenTestMockAPIClient

type ScreenTestMockAPIClient struct {
	mock.Mock
}

ScreenTestMockAPIClient - мок для API клиента, реализующий интерфейс api.Client.

func (*ScreenTestMockAPIClient) DownloadVault

DownloadVault мокирует метод DownloadVault.

func (*ScreenTestMockAPIClient) GetVaultMetadata

func (m *ScreenTestMockAPIClient) GetVaultMetadata(ctx context.Context) (*models.VaultVersion, error)

GetVaultMetadata мокирует метод GetVaultMetadata.

func (*ScreenTestMockAPIClient) ListVersions

func (m *ScreenTestMockAPIClient) ListVersions(
	ctx context.Context,
	limit,
	offset int,
) ([]models.VaultVersion, int64, error)

ListVersions мокирует метод ListVersions.

func (*ScreenTestMockAPIClient) Login

func (m *ScreenTestMockAPIClient) Login(ctx context.Context, username, password string) (string, error)

Login мокирует метод Login.

func (*ScreenTestMockAPIClient) Register

func (m *ScreenTestMockAPIClient) Register(ctx context.Context, username, password string) error

Register мокирует метод Register.

func (*ScreenTestMockAPIClient) RollbackToVersion

func (m *ScreenTestMockAPIClient) RollbackToVersion(ctx context.Context, versionID int64) error

RollbackToVersion мокирует метод RollbackToVersion.

func (*ScreenTestMockAPIClient) SetAuthToken

func (m *ScreenTestMockAPIClient) SetAuthToken(token string)

SetAuthToken мокирует метод SetAuthToken.

func (*ScreenTestMockAPIClient) UploadVault

func (m *ScreenTestMockAPIClient) UploadVault(
	ctx context.Context,
	data io.Reader,
	size int64,
	contentModifiedAt time.Time,
) error

UploadVault мокирует метод UploadVault.

type ScreenTestSuite

type ScreenTestSuite struct {
	Model *model
	Mocks struct {
		APIClient *ScreenTestMockAPIClient
	}
}

ScreenTestSuite содержит общую инфраструктуру для тестирования экранов.

func NewScreenTestSuite

func NewScreenTestSuite() *ScreenTestSuite

NewScreenTestSuite создает новую тестовую среду для экранов.

func (*ScreenTestSuite) AssertState

func (s *ScreenTestSuite) AssertState(t *testing.T, expected screenState)

AssertState проверяет, что состояние модели соответствует ожидаемому.

func (*ScreenTestSuite) AssertViewContains

func (s *ScreenTestSuite) AssertViewContains(t *testing.T, substring string)

AssertViewContains проверяет, что View() модели содержит указанный текст.

func (*ScreenTestSuite) CaptureOutput

func (s *ScreenTestSuite) CaptureOutput(t *testing.T, cmds ...tea.Cmd) string

CaptureOutput выполняет последовательность команд и возвращает финальный View.

func (*ScreenTestSuite) CaptureView

func (s *ScreenTestSuite) CaptureView(t *testing.T, cmd tea.Cmd) string

CaptureView выполняет команду и возвращает результат View().

func (*ScreenTestSuite) ExecuteCmd

func (s *ScreenTestSuite) ExecuteCmd(_ context.Context, cmd tea.Cmd) tea.Msg

ExecuteCmd выполняет команду и возвращает сообщение.

func (*ScreenTestSuite) RenderScreen

func (s *ScreenTestSuite) RenderScreen() string

RenderScreen выполняет рендеринг View() для тестирования отображения.

func (*ScreenTestSuite) SetupMockAPILogin

func (s *ScreenTestSuite) SetupMockAPILogin(username, password string, response MockResponse) *ScreenTestSuite

SetupMockAPILogin настраивает мок API клиента для метода Login.

func (*ScreenTestSuite) SetupMockAPIRegister

func (s *ScreenTestSuite) SetupMockAPIRegister(username, password string, response MockResponse) *ScreenTestSuite

SetupMockAPIRegister настраивает мок API клиента для метода Register.

func (*ScreenTestSuite) SimulateKeyPress

func (s *ScreenTestSuite) SimulateKeyPress(key tea.KeyType) (tea.Model, tea.Cmd)

SimulateKeyPress симулирует нажатие клавиши.

func (*ScreenTestSuite) SimulateKeyRune

func (s *ScreenTestSuite) SimulateKeyRune(r rune) (tea.Model, tea.Cmd)

SimulateKeyRune симулирует ввод символа.

func (*ScreenTestSuite) WithAuthToken

func (s *ScreenTestSuite) WithAuthToken(token string) *ScreenTestSuite

WithAuthToken устанавливает токен авторизации в модели.

func (*ScreenTestSuite) WithDatabase

func (s *ScreenTestSuite) WithDatabase(db *gokeepasslib.Database) *ScreenTestSuite

WithDatabase устанавливает базу данных в модели.

func (*ScreenTestSuite) WithServerURL

func (s *ScreenTestSuite) WithServerURL(url string) *ScreenTestSuite

WithServerURL устанавливает URL сервера в модели.

func (*ScreenTestSuite) WithState

func (s *ScreenTestSuite) WithState(state screenState) *ScreenTestSuite

WithState устанавливает состояние экрана в модели.

type ServerMetadataMsg

type ServerMetadataMsg struct {
	Metadata *models.VaultVersion
	Found    bool
}

ServerMetadataMsg содержит метаданные, полученные с сервера.

type SyncDownloadSuccessMsg

type SyncDownloadSuccessMsg struct {
	ReloadNeeded bool
}

SyncDownloadSuccessMsg сигнализирует об успешном скачивании.

type SyncError

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

SyncError сообщает об ошибке во время процесса синхронизации.

func (SyncError) Error

func (e SyncError) Error() string

type SyncStartedMsg

type SyncStartedMsg struct{}

SyncStartedMsg сообщение о начале синхронизации.

type SyncUploadSuccessMsg

type SyncUploadSuccessMsg struct{}

SyncUploadSuccessMsg сигнализирует об успешной загрузке.

Jump to

Keyboard shortcuts

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