-
Notifications
You must be signed in to change notification settings - Fork 69
Update MSC4311 tests to conform to the spec and better coverage #796
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
Open
turt2live
wants to merge
23
commits into
main
Choose a base branch
from
travis/msc4311-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e5a5a87
Try to modify MSC4311 test to meet new proposal
turt2live d98aae0
Merge branch 'main' into travis/msc4311-v2
kegsay 1faef0d
Merge branch 'main' into travis/msc4311-v2
MadLittleMods 35dcccf
More robust test
MadLittleMods 96b8d49
Add TODO about testing `knock_room_state`
MadLittleMods 795a951
Fix raw bytes being encoded as `event` instead of actual JSON
MadLittleMods 47474a0
Use more specific type
MadLittleMods 25ced8b
WIP: Add `TestMSC4311CreateEventInStrippedStateClientApi`
MadLittleMods 3256657
Use more robust `MustSyncUntil`
MadLittleMods cabb542
WIP: Add test for `invite_room_state` in client API
MadLittleMods 7171d67
Remove `invite_room_state` client test
MadLittleMods 18d6da2
Remove stray parallel
MadLittleMods 5d61d01
Better casing
MadLittleMods 9f29477
Merge branch 'main' into travis/msc4311-v2
MadLittleMods 633c1a2
Add client `knock_state` test
MadLittleMods 55df04e
Add `knock_room_state` test (`MustKnockRoom` not implemented)
MadLittleMods 92cdd79
Implement `srv.MustKnockRoom`
MadLittleMods 2523631
We're doing the TODO now
MadLittleMods b4ab892
Split up tests
MadLittleMods 07c60fc
Add `TestMSC4311RejectInvalidStrippedStateFederation`
MadLittleMods 4b044a1
Add note about this applying to other room versions
MadLittleMods 9b3b3da
`satisfied` typo
MadLittleMods f3134ad
Fix `JSONArraySome` logic
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package match | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/tidwall/gjson" | ||
| ) | ||
|
|
||
| func TestJSONArraySome(t *testing.T) { | ||
| t.Run("parallel", func(t *testing.T) { | ||
| for _, testCase := range []struct { | ||
| name string | ||
| jsonString string | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "passes when target is first", | ||
| jsonString: `{ "test": [1,3,5] }`, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "passes when target is last", | ||
| jsonString: `{ "test": [1,2,3] }`, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "passes when target is in the middle", | ||
| jsonString: `{ "test": [1,3,5] }`, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "fails when target not in array", | ||
| jsonString: `{ "test": [1,5,10] }`, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "fails when not array", | ||
| jsonString: `{ "test": 3 }`, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "fails when missing key", | ||
| jsonString: `{ }`, | ||
| wantErr: true, | ||
| }, | ||
| } { | ||
| t.Run(testCase.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| matcher := JSONArraySome("test", func(field gjson.Result) error { | ||
| value := field.Int() | ||
| if value == 3 { | ||
| // Found target | ||
| return nil | ||
| } | ||
| return fmt.Errorf("Expected to find target 3, found '%d'", value) | ||
| }) | ||
|
|
||
| err := matcher(gjson.Parse(testCase.jsonString)) | ||
| if (err != nil) != testCase.wantErr { | ||
| t.Errorf("JSONArraySome() error = %v, wantErr %v", err, testCase.wantErr) | ||
| } | ||
| }) | ||
| } | ||
| }) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.