Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failing while comparing apiary doc with a real service body for no visible reason #90

Closed
sameergarg opened this issue Aug 12, 2014 · 17 comments
Labels

Comments

@sameergarg
Copy link

redd apiary.apib http://localhost:9000 -d -e
info: Beginning Dredd testing...
fail: GET /greetings duration: 2681ms
fail: body: Real and expected data does not match.

request:
body:

headers:
User-Agent: Dredd/0.3.9 (Darwin 13.3.0; x64)

uri: /greetings
method: GET

expected:
headers:
content-type: text/plain; charset=utf-8

body:
hello

statusCode: 200

actual:
statusCode: 200
headers:
content-type: text/plain; charset=utf-8
content-length: 5

body:
hello

complete: 0 passing, 1 failing, 0 errors, 0 skipped
complete: Tests took 2705ms

@netmilk
Copy link
Contributor

netmilk commented Aug 12, 2014

I suspect that it can be caused by trailing newline character in the expected or real response which should not be noticeable.

@sameergarg
Copy link
Author

@netmilk I have already checked that newline or extra space scenario, unfortunately that is not the problem.

@Almad
Copy link

Almad commented Aug 14, 2014

@sameergarg Would you mind providing the related part from apiary.apib? Feel free to encrypt it with our GPG keys in case it's sensitive.

@sameergarg
Copy link
Author

@netmilk
Copy link
Contributor

netmilk commented Aug 14, 2014

When you try it to parse it with curl https://raw.githubusercontent.com/sameergarg/rest/master/apiary.apib | snowcrash you can see that hello string in the AST is wrapped with an apostrophe sign '. Remove apostrophes from the blueprint or add it to the response body of your server and it should work. I'll investigate why apostrophes are not shown in the Dredd's output result.

@sameergarg
Copy link
Author

Hi Sorry it was my mistake to add apostrophe in the version of documentation i passed. I was trying few things and i forgot to remove apostrophe.
The problem is still there even after removing the apostrophes.

@netmilk
Copy link
Contributor

netmilk commented Jan 15, 2015

@sameergarg, did you manage to figure out why it was failing? Can you provide me the backend code to test it and investigate on my own?

@netmilk netmilk closed this as completed Feb 23, 2015
@teone
Copy link

teone commented Mar 29, 2016

I'm having a similar issue:

request:
body:

headers:
    User-Agent: Dredd/1.0.8 (Darwin 15.4.0; x64)

uri: /api/tenant/cord/subscriber/1/
method: GET


expected:
body:
{
  "humanReadableName": "cordSubscriber-1",
  "id": 1,
  "service_specific_id": "123",
  "features": {
    "cdn": false,
    "uplink_speed": 1000000000,
    "downlink_speed": 1000000000,
    "uverse": true,
    "status": "enabled"
  },
  "identity": {
    "account_num": "123"
  },
  "related": {
    "instance_name": "mysite_vcpe",
    "vsg_id": 4,
    "c_tag": "432",
    "instance_id": 1,
    "wan_container_ip": null,
    "volt_id": 3,
    "s_tag": "222"
  }
}
headers:
    Content-Type: application/json

statusCode: 200


actual:
body:
{
  "humanReadableName": "cordSubscriber-1",
  "id": 1,
  "features": {
    "cdn": false,
    "uplink_speed": 1000000000,
    "downlink_speed": 1000000000,
    "uverse": true,
    "status": "enabled"
  },
  "identity": {
    "account_num": "123"
  },
  "related": {
    "instance_name": "mysite_vcpe",
    "vsg_id": 4,
    "c_tag": "432",
    "instance_id": 1,
    "wan_container_ip": null,
    "volt_id": 3,
    "s_tag": "222"
  }
}
headers:
    date: Tue, 29 Mar 2016 18:52:07 GMT
    content-type: application/json
    vary: Accept, Cookie
    allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
    server: WSGIServer/0.1 Python/2.7.6

statusCode: 200

The only thing that differ looks to be the headers section, but only content-negotiations headers should be checked in tests. What can cause this error?

I've checked withe spaces and Apiary is not about syntax errors.. .apirb is available here: http://docs.xos.apiary.io

@w-vi
Copy link
Contributor

w-vi commented Mar 29, 2016

Just out of curiosity, could it possibly be that expected header is Content-Type: application/json but the actual one is content-type: application/json without the capital C ?

@teone
Copy link

teone commented Mar 29, 2016

@w-vi I'm not sure, I think I don't have the ability to change it as the definition is:

+ Response 200 (application/json)

anyway that is not giving errors in other tests, only in this one...

@webnard
Copy link

webnard commented Mar 30, 2016

@teone @w-vi Current versions of Dredd shouldn't be affected by case-differences in headers (see #122).

@webnard
Copy link

webnard commented Mar 30, 2016

@teone You might pass your API document through drafter to see if it shows anything off. For what it's worth, I struggled getting even a basic "Hello World"-esque test to work. Dredd was adding newlines to the message body even when the file doesn't even end with one (cf #67).

@teone
Copy link

teone commented Mar 30, 2016

Thanks @webnard, passed through drafter and seems to be fine, I'll keep investigating and will report something in case of success...

@honzajavorek
Copy link
Contributor

@webnard is right that plain text hello world might be a problem due to extraneous newline (known bug), but your payloads are JSON. I'll try to get to this and reproduce the behavior. If you happen to find more info meanwhile, please share it here. Thanks!

@honzajavorek honzajavorek reopened this Mar 30, 2016
@oklaiss-gpsw
Copy link

I'm having very similar issues as well as GET requests not being tested at all.

@honzajavorek
Copy link
Contributor

Any updates on this? Do you experience the same problems with the latest version of Dredd?

@honzajavorek
Copy link
Contributor

I didn't hear back, so it seems it went away with later versions of Dredd. Thanks everyone for investigating! 👍 If this is still relevant, feel free to get back and re-open or file a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants