Register the Discourse provider in the Discourse web tests
newOperatorFixture registers Discourse's provider through world.Providers(store.ProviderSource()), as boot does: the registry, then the System tenant. The operator handler builds its entitlement options from the keys the provider owns, and only registration stamps discourse_posting with its provider, so the five TestOperator*Mapping* tests answered 422 on a freshly reset database unless another package had registered Discourse earlier in the run. They now pass alone. The member and webhook fixtures read no provider stamp and are unchanged. No assertion changes. On a reset database, go test ./internal/integrations/discourse/web/ at the parent fails TestOperatorCreateMappingValid, ...UnknownGroup, ...AutomaticGroup, ...Duplicate and TestOperatorDeleteMapping; at this commit all 13 tests pass. Over ./internal/integration/... and ./internal/integrations/discourse/... (103 tests, -p 1, reset database) names and results equal the parent's. Each of the five tests now writes Discourse's provider, operation, connection and state rows, its stamp on discourse_posting and the System tenant's user, person, org type, organization and workspace; all are idempotent across the five calls and across the full run. One break, new side: the manifest stops owning discourse_posting, so the fixture's registration fails with its message. It proves the fixture registers, not that the stamp is needed; the parent's five failures on a reset database show that.
This commit is contained in:
@@ -18,14 +18,18 @@ import (
|
||||
dcmod "git.coopcloud.tech/wiki-cafe/member-console/internal/integrations/discourse/store"
|
||||
"git.coopcloud.tech/wiki-cafe/member-console/internal/integrations/discourse/web"
|
||||
"git.coopcloud.tech/wiki-cafe/member-console/internal/testkit/dbtest"
|
||||
"git.coopcloud.tech/wiki-cafe/member-console/internal/testkit/world"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// newOperatorFixture builds the operator handler over committed fixtures
|
||||
// with per-test cleanup (the handler reads through the DB pool).
|
||||
// with per-test cleanup (the handler reads through the DB pool). It registers
|
||||
// Discourse's provider, as boot does, so the handler's entitlement options
|
||||
// exist whatever ran before.
|
||||
func newOperatorFixture(t *testing.T) (*http.ServeMux, *discoursetest.Fake) {
|
||||
t.Helper()
|
||||
database := dbtest.Open(t)
|
||||
world.New(t, database).Providers(dcmod.ProviderSource())
|
||||
fake := discoursetest.NewFake()
|
||||
t.Cleanup(fake.Close)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user