-
Notifications
You must be signed in to change notification settings - Fork 57
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
trying to fix-Init should refuse if there are existing results #560
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,15 @@ | |
import stat | ||
|
||
import pytest | ||
|
||
from exit_codes import ExitCode | ||
|
||
import cosmic_ray.cli | ||
import cosmic_ray.config | ||
import cosmic_ray.modules | ||
import cosmic_ray.mutating | ||
import cosmic_ray.plugins | ||
|
||
from cosmic_ray.work_db import WorkDB, use_db | ||
|
||
@pytest.fixture | ||
def config_file(tmpdir): | ||
|
@@ -59,11 +60,24 @@ def test_non_existent_session_file_returns_EX_NOINPUT(local_unittest_config): | |
assert cosmic_ray.cli.main(["exec", str(local_unittest_config), "foo.session"]) == ExitCode.NO_INPUT | ||
|
||
|
||
def test_non_existent_config_file_returns_EX_NOINPUT(session, local_unittest_config): | ||
cosmic_ray.cli.main(["init", local_unittest_config, str(session)]) | ||
def test_non_existent_config_file_returns_EX_NOINPUT(session, local_unittest_config,force): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test (and all tests which take a |
||
cosmic_ray.cli.main(["init", local_unittest_config, str(session),force]) | ||
assert cosmic_ray.cli.main(["exec", "no-such-file", str(session)]) == ExitCode.CONFIG | ||
|
||
|
||
|
||
def test_init_with_existing_results_no_force(session, local_unittest_config,force): | ||
"""Test that init exits without reinitializing when results exist and force=False""" | ||
with use_db(session) as database: | ||
database.num_results = 1 # Simulate existing results | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can't just set You clearly haven't run these tests because none of them run. Please don't resubmit until the tests actually run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry i commited the wrong branch will fix the changes |
||
result = cosmic_ray.cli.main(["init", local_unittest_config, str(session),force]) | ||
assert result == ExitCode.OK | ||
def test_init_with_existing_results_force(session, local_unittest_config,force=True): | ||
"""Test that init exits without reinitializing when results exist and force=False""" | ||
|
||
result = cosmic_ray.cli.main(["init", local_unittest_config, str(session),force]) | ||
assert result != ExitCode.OK | ||
|
||
@pytest.mark.skip("need to sort this API out") | ||
def test_unreadable_file_returns_EX_PERM(tmpdir, local_unittest_config): | ||
p = tmpdir.ensure("bogus.session.sqlite") | ||
|
@@ -80,8 +94,8 @@ def test_new_config_success_returns_EX_OK(monkeypatch, config_file): | |
# NOTE: We have integration tests for the happy-path for many commands, so we don't cover them explicitly here. | ||
|
||
|
||
def test_dump_success_returns_EX_OK(lobotomize, local_unittest_config, session): | ||
errcode = cosmic_ray.cli.main(["init", local_unittest_config, str(session)]) | ||
def test_dump_success_returns_EX_OK(lobotomize, local_unittest_config, session,force): | ||
errcode = cosmic_ray.cli.main(["init", local_unittest_config, str(session),force]) | ||
assert errcode == ExitCode.OK | ||
|
||
errcode = cosmic_ray.cli.main(["dump", str(session)]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this logic is incorrect. If
database.num_results
is greater than zero, it will always exit, event ifforce
isTrue
. What we want is for initialization to occur ifforce
isTrue
, no matter what the state of the existing database is.