Skip to content

Commit abc865f

Browse files
committed
internal: Rework test utils mocker. (#1913)
* Add more methods. * Conditional vcs. * Remove old mocker. * Update task runner. * Add project builder to test utils. * Update project builder. * Update project graph. * Update affected. * Update task builder. * Polish. * Fix tests.
1 parent 19bc1e6 commit abc865f

34 files changed

+1113
-999
lines changed

Cargo.lock

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/action-graph/tests/action_graph_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use moon_common::path::WorkspaceRelativePathBuf;
1111
use moon_config::{PipelineActionSwitch, TaskArgs, TaskDependencyConfig, TaskOptionRunInCI};
1212
use moon_platform::*;
1313
use moon_task::{Target, TargetLocator, Task};
14-
use moon_test_utils2::{AppContextMocker, generate_workspace_graph};
14+
use moon_test_utils2::{WorkspaceMocker, generate_workspace_graph};
1515
use moon_workspace_graph::WorkspaceGraph;
1616
use rustc_hash::{FxHashMap, FxHashSet};
1717
use starbase_sandbox::{assert_snapshot, create_empty_sandbox, create_sandbox};
@@ -63,7 +63,7 @@ fn create_rust_runtime() -> Runtime {
6363

6464
fn create_app_context() -> Arc<AppContext> {
6565
let sandbox = create_empty_sandbox();
66-
Arc::new(AppContextMocker::new(sandbox.path()).mock())
66+
Arc::new(WorkspaceMocker::new(sandbox.path()).mock_app_context())
6767
}
6868

6969
fn topo(graph: ActionGraph) -> Vec<ActionNode> {

crates/action-graph/tests/utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use moon_action_graph::{ActionGraphBuilder, ActionGraphBuilderOptions};
22
use moon_config::WorkspaceConfig;
33
use moon_platform::PlatformManager;
44
use moon_test_utils2::{
5-
AppContextMocker, generate_platform_manager_from_sandbox, generate_workspace_graph_from_sandbox,
5+
WorkspaceMocker, generate_platform_manager_from_sandbox, generate_workspace_graph_from_sandbox,
66
};
77
use moon_workspace_graph::WorkspaceGraph;
88
use std::path::{Path, PathBuf};
@@ -27,7 +27,9 @@ impl ActionGraphContainer {
2727

2828
pub fn create_builder(&self) -> ActionGraphBuilder {
2929
let config = &self.workspace_config.pipeline;
30-
let app_context = AppContextMocker::new(&self.workspace_root).mock();
30+
let app_context = WorkspaceMocker::new(&self.workspace_root)
31+
.with_all_toolchains()
32+
.mock_app_context();
3133

3234
ActionGraphBuilder::with_platforms(
3335
&self.platform_manager,

crates/affected/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ tracing = { workspace = true }
2323

2424
[dev-dependencies]
2525
moon_test_utils2 = { path = "../test-utils" }
26+
starbase_sandbox = { workspace = true }
2627
tokio = { workspace = true }
2728

2829
[lints]

0 commit comments

Comments
 (0)