Documentation
¶
Overview ¶
Package testsupport4datatug builds the stored state a host test needs to exercise DataTug's protected-project role guard end to end. Hosts import it from tests only: it takes a testing.TB, it opens no network client, and it creates the project through the same shared-project service a host serves, so a host does not have to import the DataTug domain packages to seed it.
Index ¶
Constants ¶
const ( SpaceID = "protected_project_space" OwnerUID = "protected_project_owner" MemberUID = "protected_project_member" TargetUID = "protected_project_target" OwnerContactID = "owner_contact" MemberContactID = "member_contact" TargetContactID = "target_contact" )
Identifiers of the stored fixture.
Variables ¶
This section is empty.
Functions ¶
func ContactItemRef ¶
ContactItemRef is the linkage item of a fixture contact.
func EnsureNativeContactusComposition ¶ added in v0.63.0
func EnsureNativeContactusComposition()
EnsureNativeContactusComposition explicitly composes the real Contactus extension for backend tests that exercise native Space creation. It is backend-test-only setup, not production composition, and is safe to call repeatedly: the package-level sync.Once prevents duplicate Core contributor registration in the test binary. Hosts and fixtures that compose other extensions must still register those separately.
Types ¶
type NativeBusinessSpace ¶ added in v0.63.0
type NativeBusinessSpace struct {
ID string `json:"id"`
Title string `json:"title"`
OwnerContactID string `json:"ownerContactID"`
MemberContactID string `json:"memberContactID"`
}
func CreateNativeBusinessSpaces ¶ added in v0.63.0
func CreateNativeBusinessSpaces(t testing.TB, db dal.DB, ownerUID, memberUID string) []NativeBusinessSpace
CreateNativeBusinessSpaces is test-only composition for existing native Sneat users (hosts authenticate/create those users separately). Creation, contact binding and membership epochs all use the real Core/Contactus writers; this helper never fabricates generation tokens, grant roles or financial policy.
The Contactus extension must already be composed before this helper runs: a real host composes it as part of its own startup, while backend tests that create Spaces directly call EnsureNativeContactusComposition explicitly. This helper only consumes that existing composition and never registers extensions itself, so external host fixtures keep their own composition lifecycle and do not double-register the Core Space contributor.
type ProtectedProject ¶
type ProtectedProject struct {
DB dal.DB
ProjectID string
Service *facade4datatug.SharedProjectService
// Business is the trusted native Business reader to hand to
// host4datatug.ProjectRelationshipMutationPolicies.
Business facade4datatug.BusinessSharedProjectOptions
}
ProtectedProject is a Business-admitted protected DataTug project stored in a caller-owned DAL database (in memory by default). The Space has three members, each with an active contact: the project owner (who holds the project's owner role, the only one that may manage assignments), a second member and a third member. Only the owner is linked to the project.
func NewProtectedProject ¶
func NewProtectedProject(t testing.TB) *ProtectedProject
NewProtectedProject stores the Space, its three contacts and a Business project created by the owner. It sets the reviewed plan settings through t.Setenv, so the test must not be parallel.
func NewProtectedProjectWithDatabase ¶ added in v0.60.11
func NewProtectedProjectWithDatabase(t testing.TB, db dal.DB) *ProtectedProject
NewProtectedProjectWithDatabase reuses the same fixture in a caller-owned emulator. It opens no client and never chooses a production database itself.
func (*ProtectedProject) LinkMemberAsViewer ¶ added in v0.60.11
func (p *ProtectedProject) LinkMemberAsViewer(t testing.TB)
LinkMemberAsViewer uses the existing reciprocal linkage command and native current-owner policy. This is fixture setup, not a decision-auth adapter or production entitlement proof; Business remains synthetic test evidence.
func (*ProtectedProject) ProjectItemRef ¶
func (p *ProtectedProject) ProjectItemRef() coretypes.ItemRef
ProjectItemRef is the stored project's linkage item.
func (*ProtectedProject) SetControlledConnection ¶ added in v0.60.11
func (p *ProtectedProject) SetControlledConnection(t testing.TB, catalogID string, fingerprint dataaccess.Fingerprint)
SetControlledConnection stores a test catalog descriptor. Its fingerprint is fixture metadata, never actual-source identity proof. A host opener must independently bind the real source; catalog editors have no such authority.