Documentation
¶
Index ¶
- func AliasMetamodel() *metamodel.Metamodel
- func AliasMetamodelYAML() string
- func AssertEqual(t *testing.T, got, want interface{})
- func AssertError(t *testing.T, err error)
- func AssertFileExists(t *testing.T, path string)
- func AssertFileNotExists(t *testing.T, path string)
- func AssertIsDir(t *testing.T, path string)
- func AssertLengthEqual(t *testing.T, slice interface{}, expectedLen int)
- func AssertNoError(t *testing.T, err error)
- func AssertNotEqual(t *testing.T, got, notWant interface{})
- func AssertStringContains(t *testing.T, s, substr string)
- func AssertStringNotContains(t *testing.T, s, substr string)
- func ChangeDir(t *testing.T, dir string) func()
- func CreateDir(t *testing.T, path string)
- func CreateFile(t *testing.T, path, content string)
- func RandomBool() bool
- func RandomDate() string
- func RandomEnumValue(values []string) string
- func RandomID(prefix string) string
- func RandomInt(low, high int) int
- func RandomString() string
- func ReadFile(t *testing.T, path string) string
- func RenameTestMetamodelYAML() string
- func SimpleMetamodel() *metamodel.Metamodel
- func SimpleMetamodelYAML() string
- func TempDirWithCleanup(t *testing.T) string
- func TicketMetamodel() *metamodel.Metamodel
- func WorkspaceMetamodel() *metamodel.Metamodel
- func WorkspaceMetamodelYAML() string
- type EntityBuilder
- func (b *EntityBuilder) Build() *entity.Entity
- func (b *EntityBuilder) ID(id string) *EntityBuilder
- func (b *EntityBuilder) With(key string, value interface{}) *EntityBuilder
- func (b *EntityBuilder) WithContent(content string) *EntityBuilder
- func (b *EntityBuilder) WithDescription(desc string) *EntityBuilder
- func (b *EntityBuilder) WithList(key string, values ...string) *EntityBuilder
- func (b *EntityBuilder) WithProperty(key string, value interface{}) *EntityBuilder
- func (b *EntityBuilder) WithTitle(title string) *EntityBuilder
- func (b *EntityBuilder) Without(key string) *EntityBuilder
- type EntityDefBuilder
- func (e *EntityDefBuilder) Aliases(aliases ...string) *EntityDefBuilder
- func (e *EntityDefBuilder) End() *MetamodelBuilder
- func (e *EntityDefBuilder) IDPrefix(prefix string) *EntityDefBuilder
- func (e *EntityDefBuilder) IDPrefixes(prefixes ...string) *EntityDefBuilder
- func (e *EntityDefBuilder) IDType(idType string) *EntityDefBuilder
- func (e *EntityDefBuilder) Label(label string) *EntityDefBuilder
- func (e *EntityDefBuilder) ListProp(name, propType string, required bool) *EntityDefBuilder
- func (e *EntityDefBuilder) Plural(plural string) *EntityDefBuilder
- func (e *EntityDefBuilder) Prop(name, propType string, required bool) *EntityDefBuilder
- func (e *EntityDefBuilder) PropWithDefault(name, propType string, required bool, defaultVal string) *EntityDefBuilder
- type MetamodelBuilder
- func (b *MetamodelBuilder) Build() *metamodel.Metamodel
- func (b *MetamodelBuilder) DefineEntity(name string) *EntityDefBuilder
- func (b *MetamodelBuilder) WithAutomation(auto metamodel.AutomationDef) *MetamodelBuilder
- func (b *MetamodelBuilder) WithCustomType(name string, values []string) *MetamodelBuilder
- func (b *MetamodelBuilder) WithCustomTypeDefault(name string, values []string, defaultVal string) *MetamodelBuilder
- func (b *MetamodelBuilder) WithEntity(name, label string, idPatterns []string) *MetamodelBuilder
- func (b *MetamodelBuilder) WithEntityProperty(entityName, propName, propType string, required bool) *MetamodelBuilder
- func (b *MetamodelBuilder) WithRelation(name, label string, from, to []string) *MetamodelBuilder
- func (b *MetamodelBuilder) WithRelationCardinality(name, label string, from, to []string, minOut, maxOut, minIn, maxIn *int) *MetamodelBuilder
- func (b *MetamodelBuilder) WithSetOnCreate(entityTypes []string, propName, value string) *MetamodelBuilder
- func (b *MetamodelBuilder) WithValidation(rule metamodel.ValidationRule) *MetamodelBuilder
- type RelationBuilder
- func (b *RelationBuilder) Build() *entity.Relation
- func (b *RelationBuilder) From(id string) *RelationBuilder
- func (b *RelationBuilder) To(id string) *RelationBuilder
- func (b *RelationBuilder) WithContent(content string) *RelationBuilder
- func (b *RelationBuilder) WithProperty(key string, value interface{}) *RelationBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AliasMetamodel ¶
AliasMetamodel returns a metamodel with aliases for testing alias resolution.
func AliasMetamodelYAML ¶
func AliasMetamodelYAML() string
AliasMetamodelYAML returns the YAML for AliasMetamodel().
func AssertEqual ¶
AssertEqual checks that two values are deeply equal. DeepEqual (not ==) so that slices, maps, and other uncomparable types diff instead of panicking.
func AssertError ¶
AssertError checks that an error is not nil.
func AssertFileExists ¶
AssertFileExists checks that a file exists at the given path.
func AssertFileNotExists ¶
AssertFileNotExists checks that a file does not exist at the given path.
func AssertIsDir ¶
AssertIsDir checks that a path is a directory.
func AssertLengthEqual ¶
AssertLengthEqual checks that a slice or map has the expected length.
func AssertNoError ¶
AssertNoError checks that an error is nil.
func AssertNotEqual ¶
AssertNotEqual checks that two values are not deeply equal.
func AssertStringContains ¶
AssertStringContains checks that a string contains a substring.
func AssertStringNotContains ¶
AssertStringNotContains checks that a string does not contain a substring.
func ChangeDir ¶
ChangeDir changes the current directory and returns a cleanup function that restores the original directory.
func CreateDir ¶
CreateDir creates a directory at the specified path. Creates parent directories as needed.
func CreateFile ¶
CreateFile creates a file with the given content at the specified path. Creates parent directories as needed.
func RandomEnumValue ¶
RandomEnumValue picks a random value from the given list. Panics if values is empty.
func RandomID ¶
RandomID generates a random ID with the given prefix like "PREFIX-a3f8". If prefix is empty, generates just the suffix.
func RandomInt ¶
RandomInt generates a random integer in the range [low, high]. If low > high, the values are swapped.
func RandomString ¶
func RandomString() string
RandomString generates a random string like "word-a3f8".
func RenameTestMetamodelYAML ¶
func RenameTestMetamodelYAML() string
RenameTestMetamodelYAML returns a metamodel for rename tests with requirement, decision, and depends-on/addresses relations.
func SimpleMetamodel ¶
SimpleMetamodel returns a simple metamodel for testing with requirement and decision types.
func SimpleMetamodelYAML ¶
func SimpleMetamodelYAML() string
SimpleMetamodelYAML returns a simple metamodel YAML for testing.
func TempDirWithCleanup ¶
TempDirWithCleanup creates a temporary directory for testing. Uses t.TempDir() which automatically cleans up after the test.
func TicketMetamodel ¶
TicketMetamodel returns a metamodel for ticket/issue tracking tests.
func WorkspaceMetamodel ¶
WorkspaceMetamodel returns a metamodel suitable for workspace tests with requirement, decision, stakeholder, and checklist types plus automations.
func WorkspaceMetamodelYAML ¶
func WorkspaceMetamodelYAML() string
WorkspaceMetamodelYAML returns the YAML for WorkspaceMetamodel().
Types ¶
type EntityBuilder ¶
type EntityBuilder struct {
// contains filtered or unexported fields
}
EntityBuilder provides a fluent interface for building test entities. Builders should not be reused after Build() - each call creates a fresh builder.
func Entity ¶
func Entity(entityType string) *EntityBuilder
Entity creates a simple entity builder with a random ID. The entity will have a random ID unless set explicitly with ID().
func EntityFor ¶
func EntityFor(meta *metamodel.Metamodel, entityType string) *EntityBuilder
EntityFor creates a metamodel-aware entity builder that auto-fills required properties. Panics if meta is nil or entityType is not defined in the metamodel.
func NewEntity ¶
func NewEntity(id, entityType string) *EntityBuilder
NewEntity creates a new entity builder with the given ID and type.
func (*EntityBuilder) Build ¶
func (b *EntityBuilder) Build() *entity.Entity
Build returns the built entity.
func (*EntityBuilder) ID ¶
func (b *EntityBuilder) ID(id string) *EntityBuilder
ID sets the entity ID explicitly.
func (*EntityBuilder) With ¶
func (b *EntityBuilder) With(key string, value interface{}) *EntityBuilder
With is an alias for WithProperty for more concise syntax.
func (*EntityBuilder) WithContent ¶
func (b *EntityBuilder) WithContent(content string) *EntityBuilder
WithContent sets the content of the entity.
func (*EntityBuilder) WithDescription ¶
func (b *EntityBuilder) WithDescription(desc string) *EntityBuilder
WithDescription adds a description property to the entity.
func (*EntityBuilder) WithList ¶
func (b *EntityBuilder) WithList(key string, values ...string) *EntityBuilder
WithList sets a list property value.
func (*EntityBuilder) WithProperty ¶
func (b *EntityBuilder) WithProperty(key string, value interface{}) *EntityBuilder
WithProperty adds a property to the entity.
func (*EntityBuilder) WithTitle ¶
func (b *EntityBuilder) WithTitle(title string) *EntityBuilder
WithTitle adds a title property to the entity.
func (*EntityBuilder) Without ¶
func (b *EntityBuilder) Without(key string) *EntityBuilder
Without marks a property to be skipped during auto-fill (only relevant for EntityFor).
type EntityDefBuilder ¶
type EntityDefBuilder struct {
// contains filtered or unexported fields
}
EntityDefBuilder provides a fluent interface for building entity definitions.
func (*EntityDefBuilder) Aliases ¶
func (e *EntityDefBuilder) Aliases(aliases ...string) *EntityDefBuilder
Aliases sets entity type aliases.
func (*EntityDefBuilder) End ¶
func (e *EntityDefBuilder) End() *MetamodelBuilder
End finishes building the entity and adds it to the metamodel.
func (*EntityDefBuilder) IDPrefix ¶
func (e *EntityDefBuilder) IDPrefix(prefix string) *EntityDefBuilder
IDPrefix sets a single ID prefix.
func (*EntityDefBuilder) IDPrefixes ¶
func (e *EntityDefBuilder) IDPrefixes(prefixes ...string) *EntityDefBuilder
IDPrefixes sets multiple ID prefixes.
func (*EntityDefBuilder) IDType ¶
func (e *EntityDefBuilder) IDType(idType string) *EntityDefBuilder
IDType sets the ID generation type (short, sequential, manual).
func (*EntityDefBuilder) Label ¶
func (e *EntityDefBuilder) Label(label string) *EntityDefBuilder
Label sets the entity label.
func (*EntityDefBuilder) ListProp ¶
func (e *EntityDefBuilder) ListProp(name, propType string, required bool) *EntityDefBuilder
ListProp adds a multi-select property.
func (*EntityDefBuilder) Plural ¶
func (e *EntityDefBuilder) Plural(plural string) *EntityDefBuilder
Plural sets the plural name (used for directory names).
func (*EntityDefBuilder) Prop ¶
func (e *EntityDefBuilder) Prop(name, propType string, required bool) *EntityDefBuilder
Prop adds a simple property with just type and required flag.
func (*EntityDefBuilder) PropWithDefault ¶
func (e *EntityDefBuilder) PropWithDefault(name, propType string, required bool, defaultVal string) *EntityDefBuilder
PropWithDefault adds a property with a default value.
type MetamodelBuilder ¶
type MetamodelBuilder struct {
// contains filtered or unexported fields
}
MetamodelBuilder provides a fluent interface for building test metamodels.
func NewMetamodel ¶
func NewMetamodel() *MetamodelBuilder
NewMetamodel creates a new metamodel builder.
func (*MetamodelBuilder) Build ¶
func (b *MetamodelBuilder) Build() *metamodel.Metamodel
Build returns the built metamodel, initializing the alias map.
func (*MetamodelBuilder) DefineEntity ¶
func (b *MetamodelBuilder) DefineEntity(name string) *EntityDefBuilder
DefineEntity starts building an entity definition with the fluent API. Call End() to finish.
func (*MetamodelBuilder) WithAutomation ¶
func (b *MetamodelBuilder) WithAutomation(auto metamodel.AutomationDef) *MetamodelBuilder
WithAutomation adds an automation rule to the metamodel.
func (*MetamodelBuilder) WithCustomType ¶
func (b *MetamodelBuilder) WithCustomType(name string, values []string) *MetamodelBuilder
WithCustomType adds a custom type to the metamodel.
func (*MetamodelBuilder) WithCustomTypeDefault ¶
func (b *MetamodelBuilder) WithCustomTypeDefault(name string, values []string, defaultVal string) *MetamodelBuilder
WithCustomTypeDefault adds a custom type with a default value.
func (*MetamodelBuilder) WithEntity ¶
func (b *MetamodelBuilder) WithEntity(name, label string, idPatterns []string) *MetamodelBuilder
WithEntity adds an entity definition with common defaults (simple 3-arg form).
func (*MetamodelBuilder) WithEntityProperty ¶
func (b *MetamodelBuilder) WithEntityProperty(entityName, propName, propType string, required bool) *MetamodelBuilder
WithEntityProperty adds a property to an entity definition.
func (*MetamodelBuilder) WithRelation ¶
func (b *MetamodelBuilder) WithRelation(name, label string, from, to []string) *MetamodelBuilder
WithRelation adds a relation definition to the metamodel.
func (*MetamodelBuilder) WithRelationCardinality ¶
func (b *MetamodelBuilder) WithRelationCardinality( name, label string, from, to []string, minOut, maxOut, minIn, maxIn *int, ) *MetamodelBuilder
WithRelationCardinality adds a relation with cardinality constraints.
func (*MetamodelBuilder) WithSetOnCreate ¶
func (b *MetamodelBuilder) WithSetOnCreate(entityTypes []string, propName, value string) *MetamodelBuilder
WithSetOnCreate adds an automation that sets a property when an entity is created.
func (*MetamodelBuilder) WithValidation ¶
func (b *MetamodelBuilder) WithValidation(rule metamodel.ValidationRule) *MetamodelBuilder
WithValidation appends a validation rule to the metamodel. Use for tests whose subject is the rule itself (when/then or Lua) — the rule stays at the call site while the entity-shape boilerplate comes from the builder.
type RelationBuilder ¶
type RelationBuilder struct {
// contains filtered or unexported fields
}
RelationBuilder provides a fluent interface for building test relations. Builders should not be reused after Build() - each call creates a fresh builder.
func NewRelation ¶
func NewRelation(from, relationType, to string) *RelationBuilder
NewRelation creates a new relation builder with from, type, and to already set.
func Relation ¶
func Relation(relationType string) *RelationBuilder
Relation creates a new relation builder with just the relation type. Use From() and To() to set the source and target entity IDs.
func (*RelationBuilder) Build ¶
func (b *RelationBuilder) Build() *entity.Relation
Build returns the built relation. Panics if From or To are not set.
func (*RelationBuilder) From ¶
func (b *RelationBuilder) From(id string) *RelationBuilder
From sets the source entity ID.
func (*RelationBuilder) To ¶
func (b *RelationBuilder) To(id string) *RelationBuilder
To sets the target entity ID.
func (*RelationBuilder) WithContent ¶
func (b *RelationBuilder) WithContent(content string) *RelationBuilder
WithContent sets the relation's markdown content.
func (*RelationBuilder) WithProperty ¶
func (b *RelationBuilder) WithProperty(key string, value interface{}) *RelationBuilder
WithProperty adds a property to the relation.