1
1
package gapi
2
2
3
3
import (
4
+ "strings"
4
5
"testing"
5
6
6
7
"github.com/gobs/pretty"
7
8
)
8
9
9
10
const (
10
- getFoldersJSON = `
11
- [
12
- {
11
+ getFoldersJSON = `{
13
12
"id":1,
14
13
"uid": "nErXDvCkzz",
15
14
"title": "Departmenet ABC",
@@ -23,9 +22,7 @@ const (
23
22
"updatedBy": "admin",
24
23
"updated": "2018-01-31T17:43:12+01:00",
25
24
"version": 1
26
- }
27
- ]
28
- `
25
+ }`
29
26
getFolderJSON = `
30
27
{
31
28
"id":1,
@@ -85,7 +82,17 @@ const (
85
82
)
86
83
87
84
func TestFolders (t * testing.T ) {
88
- client := gapiTestTools (t , 200 , getFoldersJSON )
85
+ mockData := strings .Repeat (getFoldersJSON + "," , 1000 ) // make 1000 folders.
86
+ mockData = "[" + mockData [:len (mockData )- 1 ] + "]" // remove trailing comma; make a json list.
87
+
88
+ // This creates 1000 + 1000 + 1 (2001, 3 calls) worth of folders.
89
+ client := gapiTestToolsFromCalls (t , []mockServerCall {
90
+ {200 , mockData },
91
+ {200 , mockData },
92
+ {200 , "[" + getFolderJSON + "]" },
93
+ })
94
+
95
+ const dashCount = 2001
89
96
90
97
folders , err := client .Folders ()
91
98
if err != nil {
@@ -94,12 +101,15 @@ func TestFolders(t *testing.T) {
94
101
95
102
t .Log (pretty .PrettyFormat (folders ))
96
103
97
- if len (folders ) != 1 {
98
- t .Error ("Length of returned folders should be 1" )
104
+ if len (folders ) != dashCount {
105
+ t .Errorf ("Length of returned folders should be %d" , dashCount )
99
106
}
100
107
if folders [0 ].ID != 1 || folders [0 ].Title != "Departmenet ABC" {
101
108
t .Error ("Not correctly parsing returned folders." )
102
109
}
110
+ if folders [dashCount - 1 ].ID != 1 || folders [dashCount - 1 ].Title != "Departmenet ABC" {
111
+ t .Error ("Not correctly parsing returned folders." )
112
+ }
103
113
}
104
114
105
115
func TestFolder (t * testing.T ) {
0 commit comments