Documentation
¶
Index ¶
- Variables
- func AssertGoldenJournals(t *testing.T, graph *logseq.Graph, caseDirName string, pages []string)
- func AssertGoldenPages(t *testing.T, graph *logseq.Graph, caseDirName string, pages []string)
- func AssertPagesDontExist(t *testing.T, graph *logseq.Graph, pages []string)
- func CaptureOutput(function func()) string
- func ExportFixtureUUID(f *TaskFixture, slug string) string
- func NewStubGraph(t *testing.T, subDir string) *logseq.Graph
- func RelativeTime() time.Time
- type Block
- type BlockOpt
- type TaskFixture
- func (f *TaskFixture) Add(blocks ...Block) *TaskFixture
- func (f *TaskFixture) AssertGoldenJournals(t *testing.T, graph *logseq.Graph, caseDirName string, pages []string)
- func (f *TaskFixture) AssertGoldenPages(t *testing.T, graph *logseq.Graph, caseDirName string, pages []string)
- func (f *TaskFixture) FakeBacklog(t *testing.T, configPage, caseDirName string) backlog.Backlog
Constants ¶
This section is empty.
Variables ¶
var ExportBuildAPIResponse = buildAPIResponse //nolint:gochecknoglobals
ExportBuildAPIResponse exposes buildAPIResponse for white-box testing.
var ExportBuildSlugMap = buildSlugMap //nolint:gochecknoglobals
ExportBuildSlugMap exposes buildSlugMap for white-box testing.
var ExportCollapseSlugs = collapseSlugs //nolint:gochecknoglobals
ExportCollapseSlugs exposes collapseSlugs for white-box testing.
var ExportExpandSlugs = expandSlugs //nolint:gochecknoglobals
ExportExpandSlugs exposes expandSlugs for white-box testing.
var ExportResolveRelativeDate = resolveRelativeDate //nolint:gochecknoglobals
ExportResolveRelativeDate exposes resolveRelativeDate for white-box testing.
Functions ¶
func AssertGoldenJournals ¶
func AssertGoldenPages ¶
func AssertPagesDontExist ¶
func CaptureOutput ¶
func CaptureOutput(function func()) string
CaptureOutput captures both stdout and stderr. It also works with the "color" package.
func ExportFixtureUUID ¶ added in v0.8.0
func ExportFixtureUUID(f *TaskFixture, slug string) string
ExportFixtureUUID returns the UUID for the given slug in the fixture (for white-box testing).
func NewStubGraph ¶ added in v0.8.0
NewStubGraph creates a test graph using the new directory structure. It uses graph-template as the base and loads test data from testdata/{subDir}/journals and testdata/{subDir}/pages.
func RelativeTime ¶
Types ¶
type Block ¶ added in v0.8.0
type Block struct {
Slug string
Marker string // content.TaskString* from logseq-go (e.g. TaskStringTodo), or "" for non-task blocks
Text string
Tags []string
Scheduled string // relative date: "+3d", "-1w", "+2m", "+1y", "" for none
Deadline string // same format as Scheduled
Priority string // "A", "B", "C", or ""
Groomed string // relative date for groomed:: property, "" means no property
JournalDay string // "2025-03-02" format; defaults to baseline date (2025-04-13)
ExtraProps map[string]string // arbitrary Logseq block properties
}
Block is a generic Logseq block fixture. Most callers use the Task() constructor which sets Marker. The framework is built on Block internally so non-task blocks (plain content, property blocks) can be added in the future without architectural changes — just add a Block constructor alongside Task().
type BlockOpt ¶ added in v0.8.0
type BlockOpt func(*Block)
BlockOpt is a functional option for configuring a Block.
func WithDeadline ¶ added in v0.8.0
WithDeadline sets the Deadline relative date.
func WithExtraProps ¶ added in v0.8.0
WithExtraProps sets arbitrary Logseq block properties.
func WithGroomed ¶ added in v0.8.0
WithGroomed sets the Groomed relative date (e.g. "-7d").
func WithJournalDay ¶ added in v0.8.0
WithJournalDay sets the journal page date ("2025-03-02").
func WithPriority ¶ added in v0.8.0
WithPriority sets the Priority ("A", "B", or "C").
func WithScheduled ¶ added in v0.8.0
WithScheduled sets the Scheduled relative date (e.g. "+3d", "-1w").
type TaskFixture ¶ added in v0.8.0
type TaskFixture struct {
// contains filtered or unexported fields
}
TaskFixture holds block definitions and generates fake API responses for a test.
func NewFixture ¶ added in v0.8.0
func NewFixture(t *testing.T, blocks ...Block) *TaskFixture
NewFixture creates a TaskFixture from the given blocks.
func (*TaskFixture) Add ¶ added in v0.8.0
func (f *TaskFixture) Add(blocks ...Block) *TaskFixture
Add appends blocks to the fixture and returns it for chaining. Panics if any new slug collides with an existing one.
func (*TaskFixture) AssertGoldenJournals ¶ added in v0.8.0
func (f *TaskFixture) AssertGoldenJournals( t *testing.T, graph *logseq.Graph, caseDirName string, pages []string, )
AssertGoldenJournals is like AssertGoldenPages but for journals/.
func (*TaskFixture) AssertGoldenPages ¶ added in v0.8.0
func (f *TaskFixture) AssertGoldenPages( t *testing.T, graph *logseq.Graph, caseDirName string, pages []string, )
AssertGoldenPages collapses UUIDs back to slugs in each output page, then compares against golden files in testdata/{caseDirName}/pages/.
func (*TaskFixture) FakeBacklog ¶ added in v0.8.0
FakeBacklog creates a backlog.Backlog backed by: - a temp graph populated from testdata/{caseDirName}/ with slugs expanded to UUIDs - a fake Logseq API returning generated JSON grouped by tag
configPage is the backlog config page name (e.g. "bk", "ov"). caseDirName is the subdirectory under testdata/ for this test case (may be empty).