stablekernel/aqueduct

Response body on test suite gives incorrect answer

rdnobrega opened this issue · 1 comments

I implemented the processing of query strings separately (without binds) and it may break the response body of some tests. I'm using the query URI part to filter and sort the data I'm sending back. However, on the test enviroment, usign harness and stuff, the response received from this endpoint is strange. To be clear, the endpoint IS returning the data correctly. Let me show on code:

//endpoint with query string to sort and filter data, and this endpoint returns a list of objects in the form of '[{"key":"val"}, {"key":"val"}, {"key":"val"}, (...) ]'
    final res3 = await harness.agent.get('/me/savings?sort_by=bank.asc,id.asc&bank=My Bank 0', headers: {'Authorization' : calcAuth(token)});
//this prints the correct result
    print(res3.body.toString());

//this list is unordered and unfiltered, as if no query string was applied at all.
    final savings2 = res2.body.as<List<dynamic>>().map( (m) => Saving()..readFromMap(m as Map<String, dynamic>)).toList();
//endpoint header, nothing special
  @Operation.get()
  Future<Response> getSavings() async {

So as you can see in the definition of get:

  Future<TestResponse> get(String path,
      {Map<String, dynamic> headers, Map<String, dynamic> query}) {
    return execute("GET", path, headers: headers, query: query);
  }

Your first parameter is path so the path for your query is /me/savings. If you want to pass query parameters you have to do it by the optional parameter query.