mirror of https://github.com/matrix-org/gomatrix
add final test and apply pre-commit hooks
This commit is contained in:
parent
0977769472
commit
be2a64b6f8
18
room_test.go
18
room_test.go
|
@ -2,9 +2,9 @@ package gomatrix
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"strings"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// example events from docs
|
||||
|
@ -12,10 +12,11 @@ var testEvent = `{
|
|||
"content": {
|
||||
"body": "eventbody123",
|
||||
"msgtype": "m.text",
|
||||
"membership": "join",
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": "<b>This is an example text message</b>"
|
||||
},
|
||||
"type": "m.room.message",
|
||||
"type": "m.room.member",
|
||||
"event_id": "$143273582443PhrSn:example.org",
|
||||
"room_id": "!726s6s6q:example.com",
|
||||
"sender": "@example:example.org",
|
||||
|
@ -76,7 +77,6 @@ func TestGetStateEvent (t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetMembershipState(t *testing.T) {
|
||||
|
||||
var e Event
|
||||
err := json.NewDecoder(strings.NewReader(testEvent)).Decode(&e)
|
||||
if err != nil {
|
||||
|
@ -84,6 +84,12 @@ func TestGetMembershipState (t *testing.T) {
|
|||
}
|
||||
r := NewRoom("test_id_001")
|
||||
r.UpdateState(&e)
|
||||
state := r.GetMembershipState("@alice:example.org")
|
||||
membState := r.GetMembershipState("@alice:example.org")
|
||||
if membState != e.Content["membership"] {
|
||||
t.Fatalf("TestGetMembershipState: Wrong membership state, expected '%s', got '%s'", e.Content["membership"], membState)
|
||||
}
|
||||
membState = r.GetMembershipState("@unkown:example.org")
|
||||
if membState != "leave" {
|
||||
t.Fatalf("TestGetMembershipState: Wrong membership state, expected 'leave', got '%s'", membState)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue