Skip to content

Commit

Permalink
Add a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jul 22, 2024
1 parent c52b767 commit 8675181
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions crates/uv/tests/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,80 @@ fn init_invalid_names() -> Result<()> {

Ok(())
}

#[test]
fn init_nested_workspace() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(indoc! {
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
"#,
})?;

let child = context.temp_dir.join("foo");
uv_snapshot!(context.filters(), context.init().current_dir(&context.temp_dir).arg(&child), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: `uv init` is experimental and may change without warning
Adding foo as member of workspace [TEMP_DIR]/
Initialized project foo in [TEMP_DIR]/foo
"###);

let grandchild = child.join("bar");
uv_snapshot!(context.filters(), context.init().current_dir(&context.temp_dir).arg(&grandchild), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: `uv init` is experimental and may change without warning
Adding bar as member of workspace [TEMP_DIR]/
Initialized project bar in [TEMP_DIR]/foo/bar
"###);

let workspace = fs_err::read_to_string(pyproject_toml)?;
insta::with_settings!({
filters => context.filters(),
}, {
assert_snapshot!(
workspace, @r###"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
[tool.uv.workspace]
members = ["foo", "foo/bar"]
"###
);
});

let pyproject = fs_err::read_to_string(child.join("pyproject.toml"))?;
insta::with_settings!({
filters => context.filters(),
}, {
assert_snapshot!(
pyproject, @r###"
[project]
name = "foo"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = []
[tool.uv]
dev-dependencies = []
"###
);
});

Ok(())
}

0 comments on commit 8675181

Please sign in to comment.