@endran/testdate
HTTP or CLI bridge for Firebase Admin
Last updated a year ago by endran .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @endran/testdate 
SYNC missed versions from official npm registry.

testdate

pipeline status coverage report

Keeping dates in test date fresh and relevant.

Description

Whenever you have are developing an application that involves dynamic behaviour based on time you run into issues with stale test dates. You need to have dates in your test data, but wever now and then tests may fail due to dates going over some threshold. Those days are gone!
With testdate you can make all your dates in testing relative to now. No limitations of file types, as long as it's plain text.

Installation

npm install @endran/testdate --save

or

yarn add @endran/testdate

Usage

Before you seed your database solution with test data run:

testdate \
    --source myTestData.augmented.csv \
    --destination myTestData.csv \
    --format "YYYY-MM-DD HH:mm:ss"

This will scan the --source file for keywords, and output fresh data to --destination. See https://devhints.io/moment for all --format options. Use --override an existing destination file, by default it will not override anything. If you want you can use punctuation marks around your data, for example when working with JSON it's nice to wrap testdate in "...", use --marks to denote the amount of marks that need to be removed.

Keywords

The --source file will be scanned for keywords. You modify dates relative to now, and you can also fix time of day. It's also possible to override formatting for a specific date.

With fixed time and custom format : __TESTDATE_now-0000-01-00@19:00:00#dddd, MMMM Do YYYY_TESTDATE__...

Everything between __TESTDATE_ and _TESTDATE__ will be considered, folowing these requirements:

  • Starts with either now+ or now-, to indicate to add or substract time relative to now.
  • Required after now, continues with date:
    • First years, YYYY (required).
    • Then months, MM.
    • Then days, DD.
  • Optionally for time, either; T for time relative to now; Or @ for fixed time of day.
    • Hours, HH.
    • Minutes, mm.
    • Seconds, ss.
  • Optionally, to add custom format for a single line, append with #<yourFormat>.
  • Optionally, to add punctuation marks for a single line, append with %<numberOfMarks>.
    • Even if you do not need custom formatting you do need to add the # token, use like #%<numberOfMarks>.
  • Each date instance must be on a single line, it may not span 2 lines.
  • No two dates may be on the same line.

Example:

Input:

Now                                 : __TESTDATE_now+0000_TESTDATE__...
Now (LL)                            : __TESTDATE_now+0000#LL_TESTDATE__...
Now in epoch seconds                : __TESTDATE_now+0000@19:00:00#X_TESTDATE__...
Today at 19                         : __TESTDATE_now+0000@19:00:00_TESTDATE__...

Plus 1 month and 5 minutes          : __TESTDATE_now+0000-01-00T00:05:00_TESTDATE__...
Minus 1 month and 5 minutes         : __TESTDATE_now-0000-01-00T00:05:00_TESTDATE__...

+10 Years                           : __TESTDATE_now+0010_TESTDATE__...
With + 5 Months                     : __TESTDATE_now+0010-05_TESTDATE__...
With +10 Days                       : __TESTDATE_now+0010-05-10_TESTDATE__...
With +3 Hours                       : __TESTDATE_now+0010-05-10T03_TESTDATE__...
With +22 Minutes                    : __TESTDATE_now+0010-05-10T03:22_TESTDATE__...
With +16 Seconds                    : __TESTDATE_now+0010-05-10T03:22:16_TESTDATE__...
With Custom Format (LL)             : __TESTDATE_now-0000-01-00T00:05:00#LL_TESTDATE__...
With Fixed Time (19h)               : __TESTDATE_now-0000-01-00@19:00:00_TESTDATE__...
With fixed time and custom format   : __TESTDATE_now-0000-01-00@19:00:00#dddd, MMMM Do YYYY_TESTDATE__...
With punctuation                    : "__TESTDATE_now-0000-01-00@19:00:00#%1_TESTDATE__"...
With formatting and punctuation     : "__TESTDATE_now-0000-01-00@19:00:00#LL%1_TESTDATE__"...

Output for testdate --source exampleInput.txt --destination exampleOutput.txt -O -F llll

Now                                 : Fri, Dec 28, 2018 11:17 AM...
Now (LL)                            : December 28, 2018...
Now in epoch seconds                : 1546021027...
Today at 19                         : Fri, Dec 28, 2018 7:17 PM...

Plus 1 month and 5 minutes          : Mon, Jan 28, 2019 11:22 AM...
Minus 1 month and 5 minutes         : Wed, Nov 28, 2018 11:12 AM...

+10 Years                           : Thu, Dec 28, 2028 11:17 AM...
With + 5 Months                     : Mon, May 28, 2029 11:17 AM...
With +10 Days                       : Thu, Jun 7, 2029 11:17 AM...
With +3 Hours                       : Thu, Jun 7, 2029 2:17 PM...
With +22 Minutes                    : Thu, Jun 7, 2029 2:39 PM...
With +16 Seconds                    : Thu, Jun 7, 2029 2:39 PM...
With Custom Format (LL)             : November 28, 2018...
With Fixed Time (19h)               : Wed, Nov 28, 2018 7:17 PM...
With fixed time and custom format   : Wednesday, November 28th 2018...
With punctuation                    : Wed, Nov 28, 2018 7:17 PM...
With formatting and punctuation     : November 28, 2018...

Help

Options:
  -V, --version             output the version number
  -S, --source <path>       Required. Location the source data.
  -D, --destination <path>  Required. Location of output.
  -F, --format <string>     Required. Format of the output.
  -O, --override            Optional. If set will override any existing destination file.
  -M, --marks <number>      Optional. Number of punctuation marks around test date. (default: 0)
  -h, --help                output usage information

License

Copyright (c) 2018 David Hardy
Copyright (c) 2018 codecentric nl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Current Tags

  • 0.0.6                                ...           latest (a year ago)

5 Versions

  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 6
Last Day 0
Last Week 5
Last Month 1
Dependencies (2)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |