Documentation
¶
Overview ¶
Package conformance provides a standard test suite for ability adapters. Any new provider backed by an ability Service interface must pass these tests to guarantee consistent pagination and error handling.
Index ¶
- Variables
- func AssertCursorEncoding(t *testing.T, secret []byte, payload capability.CursorPayload) string
- func AssertCursorRoundTrip(t *testing.T, secret []byte, payload capability.CursorPayload)
- func AssertPageInfoIsComplete(t *testing.T, page *capability.PageInfo, _ int)
- func AssertSliceNotNull[T any](t *testing.T, items []*T)
- func CanceledContext() context.Context
- func RequireInvalidArgError(t *testing.T, err error)
- func RequireListResult[T any](t *testing.T, result *capability.ListResult[T], limit int, hasMore bool)
- func RequireNotFoundError(t *testing.T, err error)
- func RequireNotImplementedError(t *testing.T, err error)
- func RequireProviderError(t *testing.T, err error)
- func RequireTimeoutError(t *testing.T, err error)
- func RunBookmarkConformance(t *testing.T, factory BookmarkServiceFactory)
- func RunExampleConformance(t *testing.T, factory ExampleServiceFactory)
- func RunForgeConformance(t *testing.T, factory ForgeServiceFactory)
- func RunGithubConformance(t *testing.T, factory GithubServiceFactory)
- func RunKanbanConformance(t *testing.T, factory KanbanServiceFactory)
- func RunMemoConformance(t *testing.T, factory MemoServiceFactory)
- func RunNoteConformance(t *testing.T, factory NoteServiceFactory)
- func RunReaderConformance(t *testing.T, factory ReaderServiceFactory)
- func TestTime() time.Time
- type BookmarkConfig
- type BookmarkService
- type BookmarkServiceFactory
- type ExampleConfig
- type ExampleListQuery
- type ExampleService
- type ExampleServiceFactory
- type ForgeConfig
- type ForgeListIssuesQuery
- type ForgeService
- type ForgeServiceFactory
- type GithubConfig
- type GithubListIssuesQuery
- type GithubPageQuery
- type GithubService
- type GithubServiceFactory
- type KanbanConfig
- type KanbanCreateTaskRequest
- type KanbanMoveTaskRequest
- type KanbanSearchQuery
- type KanbanService
- type KanbanServiceFactory
- type KanbanTaskQuery
- type KanbanUpdateTaskRequest
- type MemoConfig
- type MemoListQuery
- type MemoService
- type MemoServiceFactory
- type NoteConfig
- type NoteListQuery
- type NoteService
- type NoteServiceFactory
- type ReaderConfig
- type ReaderService
- type ReaderServiceFactory
Constants ¶
This section is empty.
Variables ¶
var CursorSecret = []byte("conformance-cursor-test-secret-v1")
CursorSecret is a shared secret for conformance cursor tests.
Functions ¶
func AssertCursorEncoding ¶
func AssertCursorEncoding(t *testing.T, secret []byte, payload capability.CursorPayload) string
AssertCursorEncoding verifies that encoding a cursor with valid data produces a non-empty string.
func AssertCursorRoundTrip ¶
func AssertCursorRoundTrip(t *testing.T, secret []byte, payload capability.CursorPayload)
AssertCursorRoundTrip verifies that a cursor can be encoded and decoded correctly.
func AssertPageInfoIsComplete ¶
func AssertPageInfoIsComplete(t *testing.T, page *capability.PageInfo, _ int)
AssertPageInfoIsComplete verifies all fields in PageInfo are set correctly.
func AssertSliceNotNull ¶
AssertSliceNotNull verifies that a slice is not nil.
func CanceledContext ¶
CanceledContext returns a context that is already canceled.
func RequireInvalidArgError ¶
RequireInvalidArgError checks that err wraps types.ErrInvalidArgument.
func RequireListResult ¶
func RequireListResult[T any](t *testing.T, result *capability.ListResult[T], limit int, hasMore bool)
RequireListResult checks that a ListResult has the expected structure including non-nil Items, non-nil Page, correct Limit, and HasMore logic.
func RequireNotFoundError ¶
RequireNotFoundError checks that err wraps types.ErrNotFound.
func RequireNotImplementedError ¶
RequireNotImplementedError checks that err wraps types.ErrNotImplemented.
func RequireProviderError ¶
RequireProviderError checks that err wraps types.ErrProvider.
func RequireTimeoutError ¶
RequireTimeoutError checks that err wraps types.ErrTimeout.
func RunBookmarkConformance ¶
func RunBookmarkConformance(t *testing.T, factory BookmarkServiceFactory)
RunBookmarkConformance runs the standard bookmark capability conformance suite. The factory must wire cfg into a fresh adapter and fake client for each subtest.
func RunExampleConformance ¶
func RunExampleConformance(t *testing.T, factory ExampleServiceFactory)
RunExampleConformance runs the standard example capability conformance suite.
func RunForgeConformance ¶
func RunForgeConformance(t *testing.T, factory ForgeServiceFactory)
RunForgeConformance runs the standard forge capability conformance suite.
func RunGithubConformance ¶
func RunGithubConformance(t *testing.T, factory GithubServiceFactory)
RunGithubConformance runs the standard GitHub capability conformance suite.
func RunKanbanConformance ¶
func RunKanbanConformance(t *testing.T, factory KanbanServiceFactory)
RunKanbanConformance runs the standard kanban capability conformance suite.
func RunMemoConformance ¶
func RunMemoConformance(t *testing.T, factory MemoServiceFactory)
RunMemoConformance runs the standard memo capability conformance suite. The factory must wire cfg into a fresh adapter and fake client for each subtest.
func RunNoteConformance ¶
func RunNoteConformance(t *testing.T, factory NoteServiceFactory)
RunNoteConformance runs the standard note capability conformance suite.
func RunReaderConformance ¶
func RunReaderConformance(t *testing.T, factory ReaderServiceFactory)
RunReaderConformance runs the standard reader capability conformance suite.
Types ¶
type BookmarkConfig ¶
type BookmarkConfig struct {
ListItems []*capability.Bookmark
ListNextCursor string
ListErr error
GetItem *capability.Bookmark
GetErr error
CreateItem *capability.Bookmark
CreateErr error
DeleteErr error
ArchiveResult *bool
ArchiveErr error
SearchItems []*capability.Bookmark
SearchNextCursor string
SearchErr error
AttachTagsErr error
DetachTagsErr error
CheckURLExists bool
CheckURLID string
CheckURLErr error
}
BookmarkConfig configures the fake backend for each bookmark conformance subtest. Fields set to non-nil/non-zero values become the fake responses; zero values produce empty/default success responses.
type BookmarkService ¶
type BookmarkService interface {
List(ctx context.Context, q *capability.BookmarkListQuery) (*capability.ListResult[capability.Bookmark], error)
Get(ctx context.Context, id string) (*capability.Bookmark, error)
Create(ctx context.Context, url string) (*capability.Bookmark, error)
Delete(ctx context.Context, id string) error
Archive(ctx context.Context, id string) (bool, error)
Search(ctx context.Context, q *capability.BookmarkSearchQuery) (*capability.ListResult[capability.Bookmark], error)
AttachTags(ctx context.Context, id string, tags []string) error
DetachTags(ctx context.Context, id string, tags []string) error
CheckURL(ctx context.Context, url string) (exists bool, id string, err error)
}
BookmarkService is the bookmark capability contract used by conformance tests.
type BookmarkServiceFactory ¶
type BookmarkServiceFactory func(t *testing.T, cfg BookmarkConfig) BookmarkService
BookmarkServiceFactory creates a fresh bookmark Service wired to a fake backend whose behavior is determined by the config parameter.
type ExampleConfig ¶
type ExampleConfig struct {
GetItem *capability.Host
GetErr error
ListItems []*capability.Host
ListErr error
CreateItem *capability.Host
CreateErr error
UpdateItem *capability.Host
UpdateErr error
DeleteErr error
HealthOk bool
HealthErr error
RawItems []any
RawCursor string
RawErr error
}
ExampleConfig configures the fake backend for each example conformance subtest.
type ExampleListQuery ¶
type ExampleListQuery = capability.ExampleListQuery
ExampleListQuery wraps pagination for listing items.
type ExampleService ¶
type ExampleService interface {
GetItem(ctx context.Context, id string) (*capability.Host, error)
ListItems(ctx context.Context, q *ExampleListQuery) (*capability.ListResult[capability.Host], error)
CreateItem(ctx context.Context, title string, tags types.KV) (*capability.Host, error)
UpdateItem(ctx context.Context, id string, data map[string]any) (*capability.Host, error)
DeleteItem(ctx context.Context, id string) error
HealthCheck(ctx context.Context) (bool, error)
ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
}
ExampleService is the example capability contract used by conformance tests.
type ExampleServiceFactory ¶
type ExampleServiceFactory func(t *testing.T, cfg ExampleConfig) ExampleService
ExampleServiceFactory creates a fresh example Service wired to a fake backend.
type ForgeConfig ¶
type ForgeConfig struct {
User *capability.ForgeUser
UserErr error
Repo *capability.ForgeRepo
RepoErr error
Issues []*capability.ForgeIssue
IssuesErr error
Issue *capability.ForgeIssue
IssueErr error
Diff *capability.ForgeCommitDiff
DiffErr error
FileContent []byte
FileContentErr error
}
ForgeConfig configures the fake backend for each forge conformance subtest.
type ForgeListIssuesQuery ¶
type ForgeListIssuesQuery = capability.ForgeListIssuesQuery
ForgeListIssuesQuery wraps pagination and filtering for listing issues.
type ForgeService ¶
type ForgeService interface {
GetUser(ctx context.Context) (*capability.ForgeUser, error)
GetRepo(ctx context.Context, owner, repo string) (*capability.ForgeRepo, error)
ListIssues(ctx context.Context, owner string, q *ForgeListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
GetIssue(ctx context.Context, owner, repo string, index int64) (*capability.ForgeIssue, error)
GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)
GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, lineStart, lineCount int) ([]byte, error)
}
ForgeService is the forge capability contract used by conformance tests.
type ForgeServiceFactory ¶
type ForgeServiceFactory func(t *testing.T, cfg ForgeConfig) ForgeService
ForgeServiceFactory creates a fresh forge Service wired to a fake backend.
type GithubConfig ¶
type GithubConfig struct {
User *capability.ForgeUser
UserErr error
UserByLogin *capability.ForgeUser
UserByLoginErr error
Repo *capability.ForgeRepo
RepoErr error
Issues []*capability.ForgeIssue
IssuesErr error
Diff *capability.ForgeCommitDiff
DiffErr error
FileContent []byte
FileContentErr error
Notifications []*capability.Notification
NotificationsErr error
Releases []*capability.Release
ReleasesErr error
}
GithubConfig configures the fake backend for each GitHub conformance subtest.
type GithubListIssuesQuery ¶
type GithubListIssuesQuery = capability.GithubListIssuesQuery
GithubListIssuesQuery wraps pagination and filtering for listing issues.
type GithubPageQuery ¶
type GithubPageQuery = capability.GithubPageQuery
GithubPageQuery wraps pagination for list operations.
type GithubService ¶
type GithubService interface {
GetUser(ctx context.Context) (*capability.ForgeUser, error)
GetUserByLogin(ctx context.Context, login string) (*capability.ForgeUser, error)
GetRepo(ctx context.Context, owner, repo string) (*capability.ForgeRepo, error)
ListIssues(ctx context.Context, owner string, q *GithubListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
GetIssue(ctx context.Context, owner, repo string, number int64) (*capability.ForgeIssue, error)
GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)
GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, lineStart, lineCount int) ([]byte, error)
ListNotifications(ctx context.Context, q *GithubPageQuery) (*capability.ListResult[capability.Notification], error)
ListReleases(ctx context.Context, owner, repo string, q *GithubPageQuery) (*capability.ListResult[capability.Release], error)
}
GithubService is the GitHub capability contract used by conformance tests.
type GithubServiceFactory ¶
type GithubServiceFactory func(t *testing.T, cfg GithubConfig) GithubService
GithubServiceFactory creates a fresh GitHub Service wired to a fake backend.
type KanbanConfig ¶
type KanbanConfig struct {
Tasks []*capability.Task
TasksErr error
Task *capability.Task
TaskErr error
CreateTaskID int
CreateTask *capability.Task
CreateErr error
UpdateTask *capability.Task
UpdateErr error
MoveTask *capability.Task
MoveErr error
DeleteErr error
CloseErr error
Columns []map[string]any
ColumnsErr error
SearchTasks []*capability.Task
SearchErr error
CheckClient bool
}
KanbanConfig configures the fake backend for each kanban conformance subtest.
type KanbanCreateTaskRequest ¶
type KanbanCreateTaskRequest = capability.KanbanCreateTaskRequest
KanbanCreateTaskRequest holds fields for creating a task.
type KanbanMoveTaskRequest ¶
type KanbanMoveTaskRequest = capability.KanbanMoveTaskRequest
KanbanMoveTaskRequest holds fields for moving a task.
type KanbanSearchQuery ¶
type KanbanSearchQuery = capability.KanbanSearchQuery
KanbanSearchQuery wraps pagination for searching tasks.
type KanbanService ¶
type KanbanService interface {
ListTasks(ctx context.Context, q *KanbanTaskQuery) (*capability.ListResult[capability.Task], error)
GetTask(ctx context.Context, id int) (*capability.Task, error)
CreateTask(ctx context.Context, req KanbanCreateTaskRequest) (*capability.Task, error)
UpdateTask(ctx context.Context, id int, req KanbanUpdateTaskRequest) (*capability.Task, error)
DeleteTask(ctx context.Context, id int) error
MoveTask(ctx context.Context, id int, req KanbanMoveTaskRequest) (*capability.Task, error)
CompleteTask(ctx context.Context, id int) error
GetColumns(ctx context.Context, projectID int) ([]map[string]any, error)
SearchTasks(ctx context.Context, q *KanbanSearchQuery) (*capability.ListResult[capability.Task], error)
}
KanbanService is the kanban capability contract used by conformance tests.
type KanbanServiceFactory ¶
type KanbanServiceFactory func(t *testing.T, cfg KanbanConfig) KanbanService
KanbanServiceFactory creates a fresh kanban Service wired to a fake backend whose behavior is determined by the config parameter.
type KanbanTaskQuery ¶
type KanbanTaskQuery = capability.KanbanTaskQuery
KanbanTaskQuery wraps pagination and filters for listing tasks.
type KanbanUpdateTaskRequest ¶
type KanbanUpdateTaskRequest = capability.KanbanUpdateTaskRequest
KanbanUpdateTaskRequest holds fields for updating a task.
type MemoConfig ¶
type MemoConfig struct {
ListItems []*capability.Memo
ListNextCursor string
ListErr error
GetItem *capability.Memo
GetErr error
CreateItem *capability.Memo
CreateErr error
UpdateItem *capability.Memo
UpdateErr error
DeleteErr error
HealthOk bool
HealthErr error
RawItems []any
RawCursor string
RawErr error
}
MemoConfig configures the fake backend for each memo conformance subtest. Fields set to non-nil/non-zero values become the fake responses; zero values produce empty/default success responses.
type MemoListQuery ¶
type MemoListQuery = capability.MemoListQuery
MemoListQuery wraps pagination for listing memos.
type MemoService ¶
type MemoService interface {
List(ctx context.Context, q *MemoListQuery) (*capability.ListResult[capability.Memo], error)
Get(ctx context.Context, name string) (*capability.Memo, error)
Create(ctx context.Context, content, visibility string) (*capability.Memo, error)
Update(ctx context.Context, name string, data map[string]any) (*capability.Memo, error)
Delete(ctx context.Context, name string) error
HealthCheck(ctx context.Context) (bool, error)
ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
}
MemoService is the memo capability contract used by conformance tests.
type MemoServiceFactory ¶
type MemoServiceFactory func(t *testing.T, cfg MemoConfig) MemoService
MemoServiceFactory creates a fresh memo Service wired to a fake backend whose behavior is determined by the config parameter.
type NoteConfig ¶
type NoteConfig struct {
ListItems []*capability.Note
ListErr error
GetItem *capability.Note
GetErr error
CreateItem *capability.Note
CreateErr error
UpdateItem *capability.Note
UpdateErr error
DeleteErr error
Content string
ContentErr error
SetContentErr error
SearchItems []*capability.Note
SearchErr error
AppInfo *capability.Note
AppInfoErr error
RawItems []any
RawCursor string
RawErr error
}
NoteConfig configures the fake backend for each note conformance subtest.
type NoteListQuery ¶
type NoteListQuery = capability.NoteListQuery
NoteListQuery wraps pagination for listing notes.
type NoteService ¶
type NoteService interface {
List(ctx context.Context, q *NoteListQuery) (*capability.ListResult[capability.Note], error)
Get(ctx context.Context, id string) (*capability.Note, error)
Create(ctx context.Context, title, content, typ, parentNoteID string) (*capability.Note, error)
Update(ctx context.Context, id, title, content string) (*capability.Note, error)
Delete(ctx context.Context, id string) error
GetContent(ctx context.Context, id string) (string, error)
SetContent(ctx context.Context, id, content string) error
Search(ctx context.Context, query string) (*capability.ListResult[capability.Note], error)
GetAppInfo(ctx context.Context) (*capability.Note, error)
ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
}
NoteService is the note capability contract used by conformance tests.
type NoteServiceFactory ¶
type NoteServiceFactory func(t *testing.T, cfg NoteConfig) NoteService
NoteServiceFactory creates a fresh note Service wired to a fake backend whose behavior is determined by the config parameter.
type ReaderConfig ¶
type ReaderConfig struct {
Feeds []*capability.Feed
FeedsErr error
CreateFeedID int64
CreateFeedErr error
Entries []*capability.Entry
EntriesTotal int64
EntriesErr error
MarkReadErr error
MarkUnreadErr error
StarErr error
UnstarErr error
}
ReaderConfig configures the fake backend for each reader conformance subtest.
type ReaderService ¶
type ReaderService interface {
ListFeeds(ctx context.Context, q *capability.ReaderFeedQuery) (*capability.ListResult[capability.Feed], error)
CreateFeed(ctx context.Context, feedURL string) (*capability.Feed, error)
ListEntries(ctx context.Context, q *capability.ReaderEntryQuery) (*capability.ListResult[capability.Entry], error)
MarkEntryRead(ctx context.Context, id int64) error
MarkEntryUnread(ctx context.Context, id int64) error
StarEntry(ctx context.Context, id int64) error
UnstarEntry(ctx context.Context, id int64) error
}
ReaderService is the reader capability contract used by conformance tests.
type ReaderServiceFactory ¶
type ReaderServiceFactory func(t *testing.T, cfg ReaderConfig) ReaderService
ReaderServiceFactory creates a fresh reader Service wired to a fake backend whose behavior is determined by the config parameter.