conformance

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 ability.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 ability.CursorPayload)

AssertCursorRoundTrip verifies that a cursor can be encoded and decoded correctly.

func AssertPageInfoIsComplete

func AssertPageInfoIsComplete(t *testing.T, page *ability.PageInfo, _ int)

AssertPageInfoIsComplete verifies all fields in PageInfo are set correctly.

func AssertSliceNotNull

func AssertSliceNotNull[T any](t *testing.T, items []*T)

AssertSliceNotNull verifies that a slice is not nil.

func CanceledContext

func CanceledContext() context.Context

CanceledContext returns a context that is already canceled.

func RequireInvalidArgError

func RequireInvalidArgError(t *testing.T, err error)

RequireInvalidArgError checks that err wraps types.ErrInvalidArgument.

func RequireListResult

func RequireListResult[T any](t *testing.T, result *ability.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

func RequireNotFoundError(t *testing.T, err error)

RequireNotFoundError checks that err wraps types.ErrNotFound.

func RequireNotImplementedError

func RequireNotImplementedError(t *testing.T, err error)

RequireNotImplementedError checks that err wraps types.ErrNotImplemented.

func RequireProviderError

func RequireProviderError(t *testing.T, err error)

RequireProviderError checks that err wraps types.ErrProvider.

func RequireTimeoutError

func RequireTimeoutError(t *testing.T, err error)

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.

func TestTime

func TestTime() time.Time

TestTime is a deterministic timestamp for cursor-based conformance tests.

Types

type BookmarkConfig

type BookmarkConfig struct {
	ListItems        []*ability.Bookmark
	ListNextCursor   string
	ListErr          error
	GetItem          *ability.Bookmark
	GetErr           error
	CreateItem       *ability.Bookmark
	CreateErr        error
	DeleteErr        error
	ArchiveResult    *bool
	ArchiveErr       error
	SearchItems      []*ability.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 BookmarkServiceFactory

type BookmarkServiceFactory func(t *testing.T, cfg BookmarkConfig) bm.Service

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    *ability.Host
	GetErr     error
	ListItems  []*ability.Host
	ListErr    error
	CreateItem *ability.Host
	CreateErr  error
	UpdateItem *ability.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 ExampleServiceFactory

type ExampleServiceFactory func(t *testing.T, cfg ExampleConfig) exsvc.Service

ExampleServiceFactory creates a fresh example Service wired to a fake backend.

type ForgeConfig

type ForgeConfig struct {
	User           *ability.ForgeUser
	UserErr        error
	Repo           *ability.ForgeRepo
	RepoErr        error
	Issues         []*ability.ForgeIssue
	IssuesErr      error
	Issue          *ability.ForgeIssue
	IssueErr       error
	Diff           *ability.ForgeCommitDiff
	DiffErr        error
	FileContent    []byte
	FileContentErr error
}

ForgeConfig configures the fake backend for each forge conformance subtest.

type ForgeServiceFactory

type ForgeServiceFactory func(t *testing.T, cfg ForgeConfig) forge.Service

ForgeServiceFactory creates a fresh forge Service wired to a fake backend.

type GithubConfig

type GithubConfig struct {
	User             *ability.ForgeUser
	UserErr          error
	UserByLogin      *ability.ForgeUser
	UserByLoginErr   error
	Repo             *ability.ForgeRepo
	RepoErr          error
	Issues           []*ability.ForgeIssue
	IssuesErr        error
	Diff             *ability.ForgeCommitDiff
	DiffErr          error
	FileContent      []byte
	FileContentErr   error
	Notifications    []*ability.Notification
	NotificationsErr error
	Releases         []*ability.Release
	ReleasesErr      error
}

GithubConfig configures the fake backend for each GitHub conformance subtest.

type GithubServiceFactory

type GithubServiceFactory func(t *testing.T, cfg GithubConfig) githubsvc.Service

GithubServiceFactory creates a fresh GitHub Service wired to a fake backend.

type KanbanConfig

type KanbanConfig struct {
	Tasks        []*ability.Task
	TasksErr     error
	Task         *ability.Task
	TaskErr      error
	CreateTaskID int
	CreateTask   *ability.Task
	CreateErr    error
	UpdateTask   *ability.Task
	UpdateErr    error
	MoveTask     *ability.Task
	MoveErr      error
	DeleteErr    error
	CloseErr     error
	Columns      []map[string]any
	ColumnsErr   error
	SearchTasks  []*ability.Task
	SearchErr    error
	CheckClient  bool
}

KanbanConfig configures the fake backend for each kanban conformance subtest.

type KanbanServiceFactory

type KanbanServiceFactory func(t *testing.T, cfg KanbanConfig) kb.Service

KanbanServiceFactory creates a fresh kanban Service wired to a fake backend whose behavior is determined by the config parameter.

type MemoConfig

type MemoConfig struct {
	ListItems      []*ability.Memo
	ListNextCursor string
	ListErr        error
	GetItem        *ability.Memo
	GetErr         error
	CreateItem     *ability.Memo
	CreateErr      error
	UpdateItem     *ability.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 MemoServiceFactory

type MemoServiceFactory func(t *testing.T, cfg MemoConfig) mm.Service

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     []*ability.Note
	ListErr       error
	GetItem       *ability.Note
	GetErr        error
	CreateItem    *ability.Note
	CreateErr     error
	UpdateItem    *ability.Note
	UpdateErr     error
	DeleteErr     error
	Content       string
	ContentErr    error
	SetContentErr error
	SearchItems   []*ability.Note
	SearchErr     error
	AppInfo       *ability.Note
	AppInfoErr    error
	RawItems      []any
	RawCursor     string
	RawErr        error
}

NoteConfig configures the fake backend for each note conformance subtest.

type NoteServiceFactory

type NoteServiceFactory func(t *testing.T, cfg NoteConfig) nt.Service

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         []*ability.Feed
	FeedsErr      error
	CreateFeedID  int64
	CreateFeedErr error
	Entries       []*ability.Entry
	EntriesTotal  int64
	EntriesErr    error
	MarkReadErr   error
	MarkUnreadErr error
	StarErr       error
	UnstarErr     error
}

ReaderConfig configures the fake backend for each reader conformance subtest.

type ReaderServiceFactory

type ReaderServiceFactory func(t *testing.T, cfg ReaderConfig) rdr.Service

ReaderServiceFactory creates a fresh reader Service wired to a fake backend whose behavior is determined by the config parameter.

Jump to

Keyboard shortcuts

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