diff --git a/pkg/client.go b/pkg/client.go index 196b3fd..fb6796e 100644 --- a/pkg/client.go +++ b/pkg/client.go @@ -97,6 +97,7 @@ func (c *Client) GetMonitor(ID int64) (Monitor, error) { return r.Monitors[0], nil } +// PageLimit is the default limit for monitors returned per page. const PageLimit = 50 // AllMonitors returns a slice of Monitors representing the monitors currently @@ -129,7 +130,8 @@ func (c *Client) AllMonitors() (monitors []Monitor, err error) { offset = r.Pagination.Offset + limit total := r.Pagination.Total - loopCondition = (offset+limit < total) + + loopCondition = offset < total } return monitors, err diff --git a/pkg/testdata/getMonitorsPage1.json b/pkg/testdata/getMonitorsPage1.json new file mode 100644 index 0000000..d4c96a1 --- /dev/null +++ b/pkg/testdata/getMonitorsPage1.json @@ -0,0 +1,1210 @@ +{ + "stat": "ok", + "pagination": { + "offset": 0, + "limit": 50, + "total": 100 + }, + "monitors": [ + { + "id": 777749809, + "friendly_name": "monitor-1", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-2", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-3", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-4", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-5", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-6", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-7", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-8", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-9", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-10", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-11", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-12", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-13", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-14", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-15", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-16", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-17", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-18", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-19", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-20", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-21", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-22", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-23", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-24", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-25", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-26", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-27", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-28", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-29", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-30", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-31", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-32", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-33", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-34", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-35", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-36", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-37", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-38", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-39", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-40", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-41", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-42", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-43", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-44", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-45", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-46", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-47", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-48", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-49", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-50", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + } + ] +} \ No newline at end of file diff --git a/pkg/testdata/getMonitorsPage2.json b/pkg/testdata/getMonitorsPage2.json new file mode 100644 index 0000000..4bc3112 --- /dev/null +++ b/pkg/testdata/getMonitorsPage2.json @@ -0,0 +1,1210 @@ +{ + "stat": "ok", + "pagination": { + "offset": 51, + "limit": 50, + "total": 100 + }, + "monitors": [ + { + "id": 777749809, + "friendly_name": "monitor-51", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-52", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-53", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-54", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-55", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-56", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-57", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-58", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-59", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-60", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-61", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-62", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-63", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-64", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-65", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-66", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-67", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-68", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-69", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-70", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-71", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-72", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-73", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-74", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-75", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-76", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-77", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-78", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-79", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-80", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-81", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-82", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-83", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-84", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-85", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-86", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-87", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-88", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-89", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-90", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-91", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-92", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-93", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-94", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-95", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-96", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-97", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-98", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-99", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + }, + { + "id": 777749809, + "friendly_name": "monitor-100", + "url": "http://www.monitor.com", + "type": 1, + "sub_type": "", + "keyword_type": "", + "keyword_value": "", + "http_username": "", + "http_password": "", + "port": "", + "interval": 900, + "status": 1, + "create_datetime": 1462565497, + "monitor_group": 0, + "is_group_main": 0, + "logs": [ + { + "type": 98, + "datetime": 1463540297, + "duration": 1054134 + } + ] + } + ] +} \ No newline at end of file diff --git a/pkg/uptimerobot_test.go b/pkg/uptimerobot_test.go index dacaf4d..b52e82c 100644 --- a/pkg/uptimerobot_test.go +++ b/pkg/uptimerobot_test.go @@ -2,6 +2,7 @@ package uptimerobot import ( "encoding/json" + "fmt" "io" "io/ioutil" "net/http" @@ -215,6 +216,55 @@ func TestGetMonitorByID(t *testing.T) { } } +func fakeGetMonitorsPagingHandler(req *http.Request) (*http.Response, error) { + var ( + data io.ReadCloser + err error + ) + req.ParseForm() + offset := req.PostForm.Get("offset") + if offset == "0" || offset == "" { + data, err = os.Open("testdata/getMonitorsPage1.json") + } else { + data, err = os.Open("testdata/getMonitorsPage2.json") + } + if err != nil { + return nil, err + } + return &http.Response{ + StatusCode: http.StatusOK, + Body: data, + }, nil +} + +func TestGetMonitorsPages(t *testing.T) { + const ( + baseName = "monitor" + numMonitors = 100 + ) + want := make([]string, numMonitors) + for i := 0; i < numMonitors; i++ { + want[i] = fmt.Sprintf("%s-%d", baseName, i+1) + } + c := New("dummy") + mockClient := MockHTTPClient{ + DoFunc: fakeGetMonitorsPagingHandler, + } + c.http = &mockClient + monitors, err := c.GetMonitors() + if err != nil { + t.Error(err) + } + if len(monitors) != numMonitors { + t.Errorf("Wanted %d monitors, but got %d", numMonitors, len(monitors)) + } + for i, m := range monitors { + if m.FriendlyName != want[i] { + t.Errorf("GetMonitors[%d] => %q, want %q", i, m.FriendlyName, want[i]) + } + } +} + func TestGetMonitors(t *testing.T) { t.Parallel() client := New("dummy")