Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
105515d5
Commit
105515d5
authored
Feb 14, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for chat history.
parent
60297a24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
group/group_test.go
group/group_test.go
+24
-3
No files found.
group/group_test.go
View file @
105515d5
...
...
@@ -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
)
...
...
@@ -126,7 +147,7 @@ func TestPermissions(t *testing.T) {
}
for
_
,
c
:=
range
badClients
{
t
.
Run
(
"bad "
+
c
.
Username
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"bad "
+
c
.
Username
(),
func
(
t
*
testing
.
T
)
{
p
,
err
:=
d
.
GetPermission
(
"test"
,
c
)
if
err
!=
ErrNotAuthorised
{
t
.
Errorf
(
"GetPermission %v: %v %v"
,
c
,
err
,
p
)
...
...
@@ -135,7 +156,7 @@ func TestPermissions(t *testing.T) {
}
for
_
,
cp
:=
range
goodClients
{
t
.
Run
(
"good "
+
cp
.
c
.
Username
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"good "
+
cp
.
c
.
Username
(),
func
(
t
*
testing
.
T
)
{
p
,
err
:=
d
.
GetPermission
(
"test"
,
cp
.
c
)
if
err
!=
nil
{
t
.
Errorf
(
"GetPermission %v: %v"
,
cp
.
c
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment