1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use alef_e2e::codegen::rust::render_cargo_toml;
#[test]
fn test_cargo_toml_contains_empty_workspace_section_in_local_mode() {
let result = render_cargo_toml(
"my-lib", // crate_name
"my_lib", // dep_name
"../../crates/my-lib", // crate_path
false, // needs_serde_json
false, // needs_mock_server
false, // needs_http_tests
false, // needs_tokio
false, // needs_tower_http
alef_e2e::config::DependencyMode::Local, // dep_mode
None, // version
&[], // features
);
// The generated Cargo.toml MUST contain an empty `[workspace]` table so the
// e2e crate is its own workspace root and never gets pulled into a parent
// crate's workspace (which would break `cargo fmt`/`cargo build`).
assert!(
result.contains("[workspace]"),
"Local mode e2e Cargo.toml must contain an empty [workspace] section so it stands alone"
);
}
#[test]
fn test_cargo_toml_contains_empty_workspace_section_in_registry_mode() {
let result = render_cargo_toml(
"my-lib", // crate_name
"my_lib", // dep_name
"../../crates/my-lib", // crate_path
false, // needs_serde_json
false, // needs_mock_server
false, // needs_http_tests
false, // needs_tokio
false, // needs_tower_http
alef_e2e::config::DependencyMode::Registry, // dep_mode
Some("0.1.0"), // version
&[], // features
);
// Registry mode e2e crates also need an empty `[workspace]` so they're
// self-contained inside any consuming project that happens to be a
// workspace.
assert!(
result.contains("[workspace]"),
"Registry mode e2e Cargo.toml must contain an empty [workspace] section so it stands alone"
);
}
#[test]
fn test_cargo_toml_contains_package_name() {
let result = render_cargo_toml(
"my-lib",
"my_lib",
"../../crates/my-lib",
false,
false,
false,
false,
false,
alef_e2e::config::DependencyMode::Local,
None,
&[],
);
assert!(
result.contains("name = \"my_lib-e2e-rust\""),
"Cargo.toml should contain the correct package name"
);
}