Gofmt and enable a test

This commit is contained in:
Tulir Asokan 2018-04-23 00:04:10 +03:00
parent fafc7f55be
commit ea965766b4
4 changed files with 11 additions and 14 deletions

View File

@ -27,7 +27,7 @@ import (
type RoomNameSource int type RoomNameSource int
const ( const (
ExplicitRoomName RoomNameSource = iota ExplicitRoomName RoomNameSource = iota
CanonicalAliasRoomName CanonicalAliasRoomName
AliasRoomName AliasRoomName
MemberRoomName MemberRoomName

View File

@ -26,7 +26,6 @@ import (
) )
func TestNewRoom_DefaultValues(t *testing.T) { func TestNewRoom_DefaultValues(t *testing.T) {
/*
room := rooms.NewRoom("!test:maunium.net", "@tulir:maunium.net") room := rooms.NewRoom("!test:maunium.net", "@tulir:maunium.net")
assert.Equal(t, "!test:maunium.net", room.ID) assert.Equal(t, "!test:maunium.net", room.ID)
assert.Equal(t, "@tulir:maunium.net", room.SessionUserID) assert.Equal(t, "@tulir:maunium.net", room.SessionUserID)
@ -36,7 +35,6 @@ func TestNewRoom_DefaultValues(t *testing.T) {
assert.Empty(t, room.GetCanonicalAlias()) assert.Empty(t, room.GetCanonicalAlias())
assert.Empty(t, room.GetTopic()) assert.Empty(t, room.GetTopic())
assert.Nil(t, room.GetSessionOwner()) assert.Nil(t, room.GetSessionOwner())
*/
} }
func TestRoom_GetCanonicalAlias(t *testing.T) { func TestRoom_GetCanonicalAlias(t *testing.T) {
@ -61,7 +59,6 @@ func TestRoom_GetTopic(t *testing.T) {
assert.Equal(t, "test topic", room.GetTopic()) assert.Equal(t, "test topic", room.GetTopic())
} }
func TestRoom_GetAliases(t *testing.T) { func TestRoom_GetAliases(t *testing.T) {
room := rooms.NewRoom("!test:maunium.net", "@tulir:maunium.net") room := rooms.NewRoom("!test:maunium.net", "@tulir:maunium.net")
addAliases(room) addAliases(room)
@ -94,7 +91,7 @@ func addCanonicalAlias(room *rooms.Room) {
func addAliases(room *rooms.Room) { func addAliases(room *rooms.Room) {
server1 := "maunium.net" server1 := "maunium.net"
room.UpdateState(&gomatrix.Event{ room.UpdateState(&gomatrix.Event{
Type: "m.room.aliases", Type: "m.room.aliases",
StateKey: &server1, StateKey: &server1,
Content: map[string]interface{}{ Content: map[string]interface{}{
"aliases": []interface{}{"#bar:maunium.net", "#test:maunium.net", "#foo:maunium.net"}, "aliases": []interface{}{"#bar:maunium.net", "#test:maunium.net", "#foo:maunium.net"},
@ -103,7 +100,7 @@ func addAliases(room *rooms.Room) {
server2 := "matrix.org" server2 := "matrix.org"
room.UpdateState(&gomatrix.Event{ room.UpdateState(&gomatrix.Event{
Type: "m.room.aliases", Type: "m.room.aliases",
StateKey: &server2, StateKey: &server2,
Content: map[string]interface{}{ Content: map[string]interface{}{
"aliases": []interface{}{"#foo:matrix.org", "#test:matrix.org"}, "aliases": []interface{}{"#foo:matrix.org", "#test:matrix.org"},
@ -114,11 +111,11 @@ func addAliases(room *rooms.Room) {
func addMembers(room *rooms.Room, count int) { func addMembers(room *rooms.Room, count int) {
user1 := "@tulir:maunium.net" user1 := "@tulir:maunium.net"
room.UpdateState(&gomatrix.Event{ room.UpdateState(&gomatrix.Event{
Type: "m.room.member", Type: "m.room.member",
StateKey: &user1, StateKey: &user1,
Content: map[string]interface{}{ Content: map[string]interface{}{
"displayname": "tulir", "displayname": "tulir",
"membership": "join", "membership": "join",
}, },
}) })
@ -127,16 +124,16 @@ func addMembers(room *rooms.Room, count int) {
content := map[string]interface{}{ content := map[string]interface{}{
"membership": "join", "membership": "join",
} }
if i % 2 == 1 { if i%2 == 1 {
content["displayname"] = fmt.Sprintf("User #%d", i+1) content["displayname"] = fmt.Sprintf("User #%d", i+1)
} }
if i % 5 == 0 { if i%5 == 0 {
content["membership"] = "invite" content["membership"] = "invite"
} }
room.UpdateState(&gomatrix.Event{ room.UpdateState(&gomatrix.Event{
Type: "m.room.member", Type: "m.room.member",
StateKey: &userN, StateKey: &userN,
Content: content, Content: content,
}) })
} }
} }

View File

@ -163,7 +163,7 @@ func (view *RoomView) GetStatus() string {
var buf strings.Builder var buf strings.Builder
if len(view.completions.list) > 0 { if len(view.completions.list) > 0 {
if view.completions.textCache != view.input.GetText() || view.completions.time.Add(10 * time.Second).Before(time.Now()) { if view.completions.textCache != view.input.GetText() || view.completions.time.Add(10*time.Second).Before(time.Now()) {
view.completions.list = []string{} view.completions.list = []string{}
} else { } else {
buf.WriteString(strings.Join(view.completions.list, ", ")) buf.WriteString(strings.Join(view.completions.list, ", "))

View File

@ -240,7 +240,7 @@ func (view *MainView) MouseEventHandler(roomView *RoomView, event *tcell.EventMo
} }
} else if isInArea(x, y, view.roomList) && event.Buttons() == tcell.Button1 { } else if isInArea(x, y, view.roomList) && event.Buttons() == tcell.Button1 {
_, rly, _, _ := msgView.GetRect() _, rly, _, _ := msgView.GetRect()
n := y-rly+1 n := y - rly + 1
if n >= 0 && n < len(view.roomIDs) { if n >= 0 && n < len(view.roomIDs) {
view.SwitchRoom(n) view.SwitchRoom(n)
} }