-
Notifications
You must be signed in to change notification settings - Fork 20
/
get-records_test.go
46 lines (41 loc) · 1.1 KB
/
get-records_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright © 2020 Mike Berezin
//
// Use of this source code is governed by an MIT license.
// Details in the LICENSE file.
package airtable
import (
"testing"
)
func TestGetRecordsConfig_Do(t *testing.T) {
table := testTable()
table.client.baseURL = mockResponse("get_records_with_filter.json").URL
sortQuery1 := struct {
FieldName string
Direction string
}{"Field1", "desc"}
sortQuery2 := struct {
FieldName string
Direction string
}{"Field2", "asc"}
records, err := table.GetRecords().
FromView("view_1").
WithFilterFormula("AND({Field1}='value_1',NOT({Field2}='value_2'))").
WithSort(sortQuery1, sortQuery2).
ReturnFields("Field1", "Field2").
InStringFormat("Europe/Moscow", "ru").
MaxRecords(100).
PageSize(10).
WithOffset("hhh").
Do()
if err != nil {
t.Errorf("there should not be an err, but was: %v", err)
}
if len(records.Records) != 3 {
t.Errorf("there should be 3 records, but was %v", len(records.Records))
}
table.client.baseURL = mockErrorResponse(400).URL
_, err = table.GetRecords().Do()
if err == nil {
t.Errorf("there should be an err, but was nil")
}
}