mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
fix: regex for api key shell export
This commit is contained in:
parent
8753e54b58
commit
97f658cd6b
2 changed files with 9 additions and 1 deletions
|
|
@ -15,7 +15,9 @@ if os.name == "nt": # Windows
|
|||
SHELL_RC_EXPORT_PATTERN = re.compile(r"^set CODEFLASH_API_KEY=(cf-.*)$", re.MULTILINE)
|
||||
SHELL_RC_EXPORT_PREFIX = "set CODEFLASH_API_KEY="
|
||||
else:
|
||||
SHELL_RC_EXPORT_PATTERN = re.compile(r'^(?!#)export CODEFLASH_API_KEY=[\'"]?(cf-[^\s"]+)[\'"]$', re.MULTILINE)
|
||||
SHELL_RC_EXPORT_PATTERN = re.compile(
|
||||
r'^(?!#)export CODEFLASH_API_KEY=(?:"|\')?(cf-[^\s"\']+)(?:"|\')?$', re.MULTILINE
|
||||
)
|
||||
SHELL_RC_EXPORT_PREFIX = "export CODEFLASH_API_KEY="
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,12 @@ class TestReadApiKeyFromShellConfig(unittest.TestCase):
|
|||
) as mock_file:
|
||||
self.assertEqual(read_api_key_from_shell_config(), None)
|
||||
mock_file.assert_called_once_with(self.test_rc_path, encoding="utf8")
|
||||
with patch(
|
||||
"builtins.open", mock_open(read_data=f'export CODEFLASH_API_KEY={self.api_key}\n')
|
||||
) as mock_file:
|
||||
self.assertEqual(read_api_key_from_shell_config(), self.api_key)
|
||||
mock_file.assert_called_once_with(self.test_rc_path, encoding="utf8")
|
||||
|
||||
|
||||
@patch("codeflash.code_utils.shell_utils.get_shell_rc_path")
|
||||
def test_no_api_key(self, mock_get_shell_rc_path):
|
||||
|
|
|
|||
Loading…
Reference in a new issue