mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Add unit test for chat history.
This commit is contained in:
parent
60297a247c
commit
105515d56e
1 changed files with 24 additions and 3 deletions
|
@ -2,6 +2,7 @@ package group
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -23,6 +24,27 @@ func TestJSTime(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestChatHistory(t *testing.T) {
|
||||
g := Group{
|
||||
description: &description{},
|
||||
}
|
||||
for i := 0; i < 2*maxChatHistory; i++ {
|
||||
g.AddToChatHistory("id", "user", ToJSTime(time.Now()), "",
|
||||
fmt.Sprintf("%v", i),
|
||||
)
|
||||
}
|
||||
h := g.GetChatHistory()
|
||||
if len(h) != maxChatHistory {
|
||||
t.Errorf("Expected %v, got %v", maxChatHistory, len(g.history))
|
||||
}
|
||||
for i, s := range h {
|
||||
e := fmt.Sprintf("%v", i+maxChatHistory)
|
||||
if s.Value.(string) != e {
|
||||
t.Errorf("Expected %v, got %v", e, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var descJSON = `
|
||||
{
|
||||
"op": [{"username": "jch","password": "topsecret"}],
|
||||
|
@ -117,7 +139,6 @@ var goodClients = []testClientPerm{
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
func TestPermissions(t *testing.T) {
|
||||
var d description
|
||||
err := json.Unmarshal([]byte(descJSON), &d)
|
||||
|
|
Loading…
Reference in a new issue