Test GetMeasurements overrides limit <= 0 with limit 100
parent
a9e7726591
commit
ff0fb5e321
|
@ -414,6 +414,46 @@ func TestService_Measurements(t *testing.T) {
|
||||||
body: `{"code":422,"message":"strconv.Atoi: parsing \"bob\": invalid syntax"}`,
|
body: `{"code":422,"message":"strconv.Atoi: parsing \"bob\": invalid syntax"}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Overrides limit less than or equal to 0 with limit 100",
|
||||||
|
fields: fields{
|
||||||
|
SourcesStore: &mocks.SourcesStore{
|
||||||
|
GetF: func(ctx context.Context, srcID int) (chronograf.Source, error) {
|
||||||
|
return chronograf.Source{
|
||||||
|
ID: 0,
|
||||||
|
}, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Databases: &mocks.Databases{
|
||||||
|
ConnectF: func(context.Context, *chronograf.Source) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
GetMeasurementsF: func(ctx context.Context, dbID string, limit, offset int) ([]chronograf.Measurement, error) {
|
||||||
|
return []chronograf.Measurement{
|
||||||
|
{
|
||||||
|
Name: "pineapple",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "cubeapple",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "pinecube",
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
queryParams: map[string]string{
|
||||||
|
"limit": "0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wants: wants{
|
||||||
|
statusCode: 200,
|
||||||
|
body: `{"measurements":[{"name":"pineapple"},{"name":"cubeapple"},{"name":"pinecube"}],"links":{"self":"/chronograf/v1/sources/0/dbs/0/measurements?limit=100\u0026offset=0","first":"/chronograf/v1/sources/0/dbs/0/measurements?limit=100\u0026offset=0","next":"/chronograf/v1/sources/0/dbs/0/measurements?limit=100\u0026offset=100"}}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue