Skip to content

Commit e2abd22

Browse files
authored
Merge pull request #34 from code-yeongyu/feature/tests
2 parents 3aad968 + 21bf092 commit e2abd22

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Test
22
on:
3+
push:
4+
branches:
5+
- master
36
pull_request:
47

58
jobs:
@@ -32,3 +35,8 @@ jobs:
3235

3336
- name: Run test
3437
run: poetry run invoke test
38+
39+
- name: Upload Code Coverage
40+
run: bash <(curl -s https://codecov.io/bash)
41+
env:
42+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

aishell/utils/make_executable_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ def make_executable_command(command: str) -> str:
88
if command.endswith('`'):
99
command = command[:-1]
1010
command = command.strip()
11-
command = command.split('User: ')[0]
11+
command = command.split('User: ')[-1]
1212
return command

aishell/utils/test/__init__.py

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from aishell.utils import make_executable_command
2+
3+
4+
def test_make_executable_command_starts_and_ends_with_newline():
5+
command = '\nls -l\n'
6+
expected_output = 'ls -l'
7+
assert make_executable_command(command) == expected_output
8+
9+
10+
def test_make_executable_command_starts_and_ends_with_backtick():
11+
command = '`python my_script.py`\n'
12+
expected_output = 'python my_script.py'
13+
assert make_executable_command(command) == expected_output
14+
15+
16+
def test_make_executable_command_starts_with_user():
17+
command = 'User: cd ..'
18+
expected_output = 'cd ..'
19+
assert make_executable_command(command) == expected_output
20+
21+
22+
def test_make_executable_command_no_leading_or_trailing_whitespace():
23+
command = 'git clone https://github.com/my_repo.git'
24+
expected_output = 'git clone https://github.com/my_repo.git'
25+
assert make_executable_command(command) == expected_output

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ allow_split_before_dict_value = false
3838
line-length = 119
3939
select = ["PLE", "PLR", "PLW", "E", "W", "F", "I", "Q", "C", "B"]
4040

41+
[tool.pytest.ini_options]
42+
addopts = ["--cov=aishell"]
43+
44+
4145
[tool.poetry.dependencies]
4246
python = "^3.9"
4347
poetry = "^1.3.1"

0 commit comments

Comments
 (0)