ta2edchimp / opt-cli

Execute CLI Statements based upon Opt-In / Opt-Out Rules.
MIT License
21 stars 2 forks source link

Tests failing on master #212

Closed sudo-suhas closed 7 years ago

sudo-suhas commented 7 years ago

I was trying to fix a bug but found that 3 tests were failing on master branch:

λ yarn test
yarn test v0.27.5
$ ava

   12 passed
   3 failed

   1. lib » check explicit opt-ins & opt-outs (via env vars)
   retrieved opts should equal expected opts
  t.deepEqual(retrievedOpts, expectedOpts, 'retrieved opts should equal expected opts')
              |              |
              |              Object{"ENV-VAR-OPTED-IN-FOO-RULE":true,"ENV-VAR-OPTED-IN-BAR-RULE":true,"ENV-VAR-OPTED-OUT-FOO-RULE":false,"ENV-VAR-OPTED-OUT-BAR-RULE":false}
              Object{"ENV-VAR-OPTED-IN-FOO-RULE:ENV-VAR-OPTED-IN-BAR-RULE":true,"ENV-VAR-OPTED-OUT-FOO-RULE:ENV-VAR-OPTED-OUT-BAR-RULE":false}

      Test.fn (lib.js:68:5)
    _combinedTickCallback (internal/process/next_tick.js:141:11)
    process._tickCallback (internal/process/next_tick.js:180:9)

   2. lib » test for particular opt-ins (env var existing)
   ENV-VAR-OPTED-IN-FOO-RULE & ENV-VAR-OPTED-IN-BAR-RULE should be true
  t.true(testOptIn(['ENV-VAR-OPTED-IN-FOO-RULE', 'ENV-VAR-OPTED-IN-BAR-RULE']), 'ENV-VAR-OPTED-IN-FOO-RULE & ENV-VAR-OPTED-IN-BAR-RULE should be true')
         |
         false

      Test.fn (lib.js:112:3)
    _combinedTickCallback (internal/process/next_tick.js:141:11)
    process._tickCallback (internal/process/next_tick.js:180:9)

   3. lib » test for particular opt-outs (env var existing)
   ENV-VAR-OPTED-OUT-FOO-RULE & ENV-VAR-OPTED-OUT-BAR-RULE should be true
  t.true(testOptOut(['ENV-VAR-OPTED-OUT-FOO-RULE', 'ENV-VAR-OPTED-OUT-BAR-RULE']), 'ENV-VAR-OPTED-OUT-FOO-RULE & ENV-VAR-OPTED-OUT-BAR-RULE should be true')
         |
         false

      Test.fn (lib.js:174:3)
    _combinedTickCallback (internal/process/next_tick.js:141:11)
    process._tickCallback (internal/process/next_tick.js:180:9)
error Command failed with exit code 1.

More info:

λ node --version
v8.2.1

λ npm --version
5.3.0

λ yarn --version
0.27.5

λ systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.15063 N/A Build 15063
ta2edchimp commented 7 years ago

Is this still reproducible for you?
Because for me, it's not.

sudo-suhas commented 7 years ago

Yes it is:

λ yarn test
yarn run v1.2.1
$ ava

  12 passed
  3 failed

  lib » check explicit opt-ins & opt-outs (via env vars)
  E:\Projects\repos\opt-cli\test\lib.js:68

   67:
   68:   t.deepEqual( retrievedOpts, expectedOpts, 'retrieved opts should equal expected opts' );
   69: } );

  retrieved opts should equal expected opts

  Difference:

    {
  -   'ENV-VAR-OPTED-IN-FOO-RULE:ENV-VAR-OPTED-IN-BAR-RULE': true,
  -   'ENV-VAR-OPTED-OUT-FOO-RULE:ENV-VAR-OPTED-OUT-BAR-RULE': false,
  +   'ENV-VAR-OPTED-IN-BAR-RULE': true,
  +   'ENV-VAR-OPTED-IN-FOO-RULE': true,
  +   'ENV-VAR-OPTED-OUT-BAR-RULE': false,
  +   'ENV-VAR-OPTED-OUT-FOO-RULE': false,
    }

  lib » test for particular opt-ins (env var existing)
  E:\Projects\repos\opt-cli\test\lib.js:112

   111:
   112:   t.true(
   113:     testOptIn( [ 'ENV-VAR-OPTED-IN-FOO-RULE', 'ENV-VAR-OPTED-IN-BAR-RULE' ] ),

  ENV-VAR-OPTED-IN-FOO-RULE & ENV-VAR-OPTED-IN-BAR-RULE should be true

  Value is not `true`:

  false

  testOptIn([ENV-VAR-OPTED-IN-FOO-RULE,ENV-VAR-OPTED-IN-BAR-RULE])
  => false

  [ENV-VAR-OPTED-IN-FOO-RULE,ENV-VAR-OPTED-IN-BAR-RULE]
  => [
    'ENV-VAR-OPTED-IN-FOO-RULE',
    'ENV-VAR-OPTED-IN-BAR-RULE',
  ]

  lib » test for particular opt-outs (env var existing)
  E:\Projects\repos\opt-cli\test\lib.js:174

   173:
   174:   t.true(
   175:     testOptOut( [ 'ENV-VAR-OPTED-OUT-FOO-RULE', 'ENV-VAR-OPTED-OUT-BAR-RULE' ] ),

  ENV-VAR-OPTED-OUT-FOO-RULE & ENV-VAR-OPTED-OUT-BAR-RULE should be true

  Value is not `true`:

  false

  testOptOut([ENV-VAR-OPTED-OUT-FOO-RULE,ENV-VAR-OPTED-OUT-BAR-RULE])
  => false

  [ENV-VAR-OPTED-OUT-FOO-RULE,ENV-VAR-OPTED-OUT-BAR-RULE]
  => [
    'ENV-VAR-OPTED-OUT-FOO-RULE',
    'ENV-VAR-OPTED-OUT-BAR-RULE',
  ]
error Command failed with exit code 1.

Note: I fetched in the latest master and ran yarn before running the tests.

ta2edchimp commented 7 years ago

Could you please fetch fix/windows-tests and test again?
I'm pretty sure it's the delimiter in the env. vars being hardcoded as ':', which is not correct for Windows machines (where it should be ';' instead).

sudo-suhas commented 7 years ago

Yes, the failing tests are fixed in fix/windows-tests.

ta2edchimp commented 7 years ago

The changed tests are merged and now available via master.
Thanks for checking and reporting the issue in the first place!