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

replaced ISO 8601 test with regular expression #260

Conversation

tzemanovic
Copy link
Contributor

Hi,

I've recently finished a backend impl (#202), but had trouble with the postman test, because SQLite I've used for the project uses 3 more decimals for microseconds, which get lost in the new Date(t).toISOString() conversion and fail the tests, even though it's a valid ISO 8601 date format.

I've adapted the regex from https://stackoverflow.com/a/3143231/3210255.

I also tried to set the regex as a variable in the collection with:

{
  "variable": [
    {
      "name": "iso8601",
      "value": "/^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/",
      "type": "RegExp"
    }
  ], ...
}

and using it in the tests with:

ps.variables.get('iso8601')

to avoid repetition, but I couldn't get it to work in newman (with latest version 4.1.0), only in postman, so I left it out.

@anishkny anishkny merged commit 09e9626 into gothinkster:master Oct 29, 2018
@schnef
Copy link

schnef commented Feb 27, 2020

There is a problem in the regex for timestamps with a "Z" at the end. The regex currently is: /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/ but should be:
/^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+(?:[+-][0-2]\\d:[0-5]\\d)|Z$/, i.e. the last `)' currently is at the wrong position.

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

Successfully merging this pull request may close these issues.

4 participants