Skip to content

test: simplify model creation in tests#1887

Merged
kian99 merged 3 commits intocanonical:v3from
kian99:simplify-test-model-creation
Feb 26, 2026
Merged

test: simplify model creation in tests#1887
kian99 merged 3 commits intocanonical:v3from
kian99:simplify-test-model-creation

Conversation

@kian99
Copy link
Contributor

@kian99 kian99 commented Feb 25, 2026

Description

This PR does 2 things,

  1. It simplifies the test environments we have, merging JimmWithControllers and WebsocketEnv. There were no usages of the former except within the latter, so I've merged them, keeping the name JimmWithControllers as I think it's clearer.
  2. Removes any model creation from within the environment setup. Any tests that need to create a model must now create them within the test.

I had AI do some of the refactoring and it made what I think is a nice change. It created helper functions CreateModelForBob and CreateModelForCharlie. Our tests always used these users and setup permissions for them so I've called out their roles (and Alice's role) in a godoc. Charlie and Bob have add-model permissions on all controllers and Alice is a superuser.

The tests, I think, are easy to read when you have the above in mind.

As an interesting note, creation of a model + teardown consumes about 3s.

Engineering checklist

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

@kian99 kian99 requested a review from a team as a code owner February 25, 2026 10:19
@kian99 kian99 changed the title Simplify test model creation test: simplify model creation in tests Feb 25, 2026
@kian99 kian99 force-pushed the simplify-test-model-creation branch from 5df5bd5 to e54ec6f Compare February 25, 2026 10:31
@kian99 kian99 force-pushed the simplify-test-model-creation branch from e54ec6f to 037bb11 Compare February 25, 2026 12:20
Copy link
Contributor

@ale8k ale8k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM nice work on this cleans it up a lot, I would prefer we remove the names inside of function signatures though and just pass a user.

@kian99 kian99 merged commit 6619c22 into canonical:v3 Feb 26, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants