Skip to content

Commit

Permalink
Merge pull request #2 from botcity-dev/FIX/error-sending-an-empty-ver…
Browse files Browse the repository at this point in the history
…sion-to-deploy

FIX: Set version is required
  • Loading branch information
joao-voltarelli authored Jun 2, 2023
2 parents e2fbc08 + 26dfa0d commit 59e2828
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Binary file modified src/__pycache__/action.cpython-311.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion src/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def _get_args() -> argparse.Namespace:
action="store")
parser.add_argument("-r", "--release", help="Will the release", dest='release',
type=lambda x: bool(strtobool(x)), action="store")
parser.add_argument("-v", "--version", help="New version to bot", type=str, action="store")
parser.add_argument("-v", "--version", help="New version to bot", type=str, action="store", required=True)
parser.add_argument("-p", "--path", help="Path to github action repository", type=str, action="store")
parser.add_argument("-bp", "--botPath", help="Path to compress bot", type=str, action="store")
parser.add_argument("-bi", "--botId", help="Bot ID that will be modified.", type=str, action="store")
Expand Down Expand Up @@ -260,6 +260,9 @@ def run(self):
self.filepath = self._get_file_path()
bot = self._exist_bot()

if not self.args.version:
raise ValueError("Version is required.")

if self.args.deploy or bot is None:
self.deploy()
self.update()
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,15 @@ def test_set_version(action_logged_mocked: Action):
action_logged_mocked.set_version(bot={'version': '1.0'})
assert action_logged_mocked.args.version == '1.0'

action_logged_mocked.args.version = ''
action_logged_mocked.set_version(bot={'version': '1.0'})
assert action_logged_mocked.args.version == '1.0'

def test_run_version_none(action_logged_mocked, args_mocked):
args_mocked[8] = ""
with pytest.raises(ValueError):
with patch("sys.argv", args_mocked):
os.environ['SERVER'] = 'https://testing.com'
os.environ['LOGIN'] = '123'
os.environ['KEY'] = '123'
action_logged_mocked.run()

0 comments on commit 59e2828

Please sign in to comment.