Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Must[Get|Set]DisplayName and use MustUploadKeys in more places #755

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Jan 14, 2025

Small refactor to add a few more helpers. The hitlist for this can be discovered using grep --only-matching -Er '\[\]string\{\"_matrix\".*\}' tests | grep -E --only-matching '\[\]string.*' | sort | uniq -c | sort which currently spits out:

...
   4 []string{"_matrix", "client", "v3", "account", "whoami"}
   4 []string{"_matrix", "client", "v3", "devices"}
   4 []string{"_matrix", "client", "v3", "directory", "room", aliasName}
   4 []string{"_matrix", "client", "v3", "logout"}
   4 []string{"_matrix", "client", "v3", "rooms", roomID, "send", "m.room.message", "txn-1"}, client.WithJSONBody(t, map[string]interface{}
   4 []string{"_matrix", "client", "v3", "rooms", roomID, "state", "m.room.topic"}
   5 []string{"_matrix", "client", "v3", "rooms", roomID, "kick"}
   5 []string{"_matrix", "client", "v3", "rooms", roomID, "state", "m.room.member", bob.UserID}
   5 []string{"_matrix", "client", "v3", "rooms", roomID, "state", "m.room.power_levels"}
   6 []string{"_matrix", "client", "v3", "keys", "claim"}
   6 []string{"_matrix", "client", "v3", "keys", "device_signing", "upload"}
   6 []string{"_matrix", "client", "v3", "login"}, client.WithJSONBody(t, map[string]interface{}
   6 []string{"_matrix", "client", "v3", "rooms", roomID, "members"}
   6 []string{"_matrix", "client", "v3", "rooms", roomID, "state", "m.room.name"}
   6 []string{"_matrix", "client", "v3", "sync"}
   7 []string{"_matrix", "client", "v1", "rooms", roomID, "relations", rootEventID}
   7 []string{"_matrix", "client", "v3", "login"}
   7 []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}
   7 []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}
   7 []string{"_matrix", "client", "v3", "search"}
   7 []string{"_matrix", "client", "v3", "user_directory", "search"}
   8 []string{"_matrix", "client", "v3", "devices", newDeviceID}
   9 []string{"_matrix", "client", "v3", "keys", "query"}
   9 []string{"_matrix", "client", "v3", "register"}
  10 []string{"_matrix", "client", "v1", "rooms", root, "hierarchy"}
  10 []string{"_matrix", "client", "v3", "keys", "upload"}
  18 []string{"_matrix", "client", "v3", "rooms", roomID, "messages"}

The point of helpers in the CSAPI struct is:

  • to provide a shortcut when the test isn't really testing that endpoint (so it just needs it as boring setup code)
  • it's used multiple times by different tests

Originally we didn't have enough tests to meet that 2nd bullet point but this hasn't been true for quite some time, but we never revisited adding helpers until now.

@kegsay kegsay requested review from a team as code owners January 14, 2025 09:22
@kegsay kegsay merged commit 0c19e2d into main Jan 21, 2025
4 checks passed
@kegsay kegsay deleted the kegan/api-helpers branch January 21, 2025 08:18
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.

2 participants