|
|
@ -68,3 +68,68 @@ func TestSendMessageByConvID(t *testing.T) { |
|
|
|
t.Errorf(`res.MessageID: expected %d, got %d`, expected, uint(*res.MessageID)) |
|
|
|
t.Errorf(`res.MessageID: expected %d, got %d`, expected, uint(*res.MessageID)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestCreateFilterString(t *testing.T) { |
|
|
|
|
|
|
|
tables := []struct { |
|
|
|
|
|
|
|
channel chat1.ChatChannel |
|
|
|
|
|
|
|
expected string |
|
|
|
|
|
|
|
}{ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
chat1.ChatChannel{}, |
|
|
|
|
|
|
|
``, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "faketeam", MembersType: TEAM}, |
|
|
|
|
|
|
|
`{"name":"faketeam","members_type":"team"}`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "user1,user2", MembersType: USER}, |
|
|
|
|
|
|
|
`{"name":"user1,user2","members_type":"impteamnative"}`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, table := range tables { |
|
|
|
|
|
|
|
if result := createFilterString(table.channel); result != table.expected { |
|
|
|
|
|
|
|
t.Errorf(`Expected "%s", got "%s"`, table.expected, result) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestCreateFiltersString(t *testing.T) { |
|
|
|
|
|
|
|
tables := []struct { |
|
|
|
|
|
|
|
channel []chat1.ChatChannel |
|
|
|
|
|
|
|
expected string |
|
|
|
|
|
|
|
}{ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
[]chat1.ChatChannel{}, |
|
|
|
|
|
|
|
``, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
[]chat1.ChatChannel{ |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "faketeam1", MembersType: TEAM}, |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "faketeam2", MembersType: TEAM}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
`[{"name":"faketeam1","members_type":"team"},{"name":"faketeam2","members_type":"team"}]`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
[]chat1.ChatChannel{ |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "user1,user2", MembersType: USER}, |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "user3,user4", MembersType: USER}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
`[{"name":"user1,user2","members_type":"impteamnative"},{"name":"user3,user4","members_type":"impteamnative"}]`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
[]chat1.ChatChannel{ |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "user1,user2", MembersType: USER}, |
|
|
|
|
|
|
|
chat1.ChatChannel{Name: "faketeam1", MembersType: TEAM}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
`[{"name":"user1,user2","members_type":"impteamnative"},{"name":"faketeam1","members_type":"team"}]`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, table := range tables { |
|
|
|
|
|
|
|
if result := createFiltersString(table.channel); result != table.expected { |
|
|
|
|
|
|
|
t.Errorf(`Expected "%s", got "%s"`, table.expected, result) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|