Documentation
¶
Overview ¶
Package orgtest is the organization counterpart of authtest's user factory: build an organization in memory, then save it through the plugin's real Go API so every rule and hook runs.
It lives in the organization module, not in authtest, because the core module cannot import the organization plugin. Like authtest it imports no database driver: the test that uses it imports its own.
Index ¶
Constants ¶
const DefaultOrgName = "Test Organization"
DefaultOrgName is the name NewOrganization gives when the test passes none.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory builds and saves organizations for one authtest.Env.
func New ¶
New returns the factory for env, whose Auth must have the organization plugin wired; a missing plugin fails the test.
func (*Factory) AddMember ¶
func (f *Factory) AddMember(orgID, userID string, role organization.Role)
AddMember adds userID to orgID with role through the plugin's AddMember; a refusal fails the test.
func (*Factory) NewOrganization ¶
func (f *Factory) NewOrganization(ownerID, name string) OrgFixture
NewOrganization builds an OrgFixture without touching the database: DefaultOrgName unless the test passes a name, a random slug that fits organization.SlugPattern, and ownerID as its creator. The organization's id is given by the plugin at SaveOrganization, as for any organization.
func (*Factory) SaveOrganization ¶
func (f *Factory) SaveOrganization(o OrgFixture) organization.Org
SaveOrganization creates f through the plugin (CreateFor, then AddMember for each member), so slug, role and limit rules and every hook run, and returns the stored organization. Any refusal fails the test.
type Member ¶
type Member struct {
UserID string
Role organization.Role
}
Member is one membership an OrgFixture is saved with.