Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Dec 14, 2019

No description provided.

@ghost ghost requested review from Suor, efiop and pared December 14, 2019 00:20
("0.20.8", "0.19.0", True),
],
)
def test_is_outdated(latest, current, result, updater):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move .is_outdated and .check to the unit tests, since they are testing a single unit, in this case, a method.

Comment on lines +55 to +57
updater.check()
updater.check()
updater.check()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this 3 times? It would be nice to have a comment explaining this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, I imagine that is to "test" the lock mechanism or something. @efiop , could you give more details about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, to check that we hit the logic when there is no updater file, when there is one and once more. It is pretty old code, so sorry for it being weird like that. 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if all 3 .check() calls are noop then test will pass.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Suor Yes.

if not os.getenv("TRAVIS_EVENT_TYPE") == "cron":
return

monkeypatch.delenv("CI")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not enough to make .check() run. There is also a DVC_TEST env var. Also, the fact that it ran smooth means that we are not checking anything here. Add a spy probably.

@efiop
Copy link
Contributor

efiop commented Dec 16, 2019

@MrOutis Test failing. Please take a look,

os.getenv("TRAVIS_EVENT_TYPE") != "cron",
reason = "Only run on travis CRON to avoid generating too much logs"
def test_check(updater, monkeypatch):
monkeypatch.setenv("DVC_TEST", "true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already "true".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a DVC_TEST env var

Then I didn't get this comment, @Suor

Copy link
Contributor

@Suor Suor Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are setting it to true, but it is already true. Basically test is noop since I changed Updater to not run in tests several months ago.

To fix this properly you need:

  • add some mock/spy to check that updater.check() is actually doing something
  • fix it not doing something by adjusting env

@efiop efiop assigned ghost Dec 17, 2019
@efiop efiop added refactoring Factoring and re-factoring testing Related to the tests and the testing infrastructure labels Dec 17, 2019
@ghost ghost requested review from Suor and pared December 17, 2019 18:19
@efiop efiop merged commit 825e9fc into treeverse:master Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Factoring and re-factoring testing Related to the tests and the testing infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants