Skip to content

Commit bae159e

Browse files
committed
Add a test
1 parent 443d415 commit bae159e

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

tests/test_rust.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class TestRustListDependencies(unittest.TestCase):
13-
def test_success(self) -> None:
13+
def test_separate_crates(self) -> None:
1414
files = {
1515
pathlib.Path('rust-toolchain'): textwrap.dedent("""\
1616
1.42.0
@@ -60,6 +60,40 @@ def test_success(self) -> None:
6060
actual = sorted(RustLanguage(config=None).list_dependencies(tempdir / 'crates' / 'a' / 'src' / 'lib.rs', basedir=tempdir))
6161
self.assertEqual(actual, expected)
6262

63+
def test_mono_crate(self) -> None:
64+
files = {
65+
pathlib.Path('rust-toolchain'): textwrap.dedent("""\
66+
1.42.0
67+
""").encode(),
68+
pathlib.Path('Cargo.toml'): textwrap.dedent("""\
69+
[package]
70+
name = "my_competitive_library"
71+
version = "0.0.0"
72+
edition = "2018"
73+
""").encode(),
74+
pathlib.Path('src', 'lib.rs'): textwrap.dedent("""\
75+
pub mod a;
76+
pub mod b;
77+
pub mod c;
78+
""").encode(),
79+
pathlib.Path('src', 'a.rs'): textwrap.dedent("""\
80+
pub struct A;
81+
""").encode(),
82+
pathlib.Path('src', 'b.rs'): textwrap.dedent("""\
83+
pub struct B;
84+
""").encode(),
85+
pathlib.Path('src', 'c.rs'): textwrap.dedent("""\
86+
pub struct C;
87+
""").encode(),
88+
}
89+
90+
with tests.utils.load_files_pathlib(files) as tempdir:
91+
expected = [tempdir / 'src' / f'{stem}.rs' for stem in ['a', 'b', 'c', 'lib']]
92+
93+
for file_stem in ['a', 'b', 'c', 'lib']:
94+
actual = sorted(RustLanguage(config=None).list_dependencies(tempdir / 'src' / f'{file_stem}.rs', basedir=tempdir))
95+
self.assertEqual(actual, expected)
96+
6397

6498
class TestRustVerification(unittest.TestCase):
6599
def test_success(self) -> None:

0 commit comments

Comments
 (0)