Repository: MystenLabs/sui
File: external-crates/move/crates/move-package-alt/src/package/root_package.rs (Rust)

Code before:
    }

    #[test(tokio::test)]
    async fn test_cannot_override_default_environments() {
        let project = test_utils::project()
            .file(
                "Move.toml",
                &basic_manifest_with_env(
                    "graph",
                    "0.0.1",
                    DEFAULT_ENV_NAME,
                    "DIFFERENT_FROM_DEFAULT",
                ),
            )
            .build();

        let environment =
            Environment::new(DEFAULT_ENV_NAME.to_string(), DEFAULT_ENV_ID.to_string());

        let load_err = RootPackage::<Vanilla>::load(&project.root(), environment, vec![])
            .await
            .unwrap_err();
        assert_eq!(
            load_err.to_string(),
            "Cannot override default environments. Environment `_test_env` is a system environment and cannot be overridden."
        );
    }

    #[test(tokio::test)]
    async fn test_load_and_check_for_env() {
        let (_, root_path) = setup_test_move_project().await;

        let path = root_path.join("graph");
        // should fail as devnet does not exist in the manifest
        assert!(
            RootPackage::<Vanilla>::load(
                &path,
                Environment::new("devnet".to_string(), "abcd1234".to_string()),
                vec![]
            )
            .await
            .is_err()
        );
    }

    /// This just ensures that `RootPackage` does the `rename-from` validation; see
    /// [crate::graph::rename_from::tests] for more detailed tests that operate directly on the
    /// package graph
    #[test(tokio::test)]
    async fn test_rename_from() {
        // `a` depends on `b` which has name `b_name`, but there is no rename-from

Review comment (suggestion):
```suggestion
        assert_snapshot!(
            load_err.to_string(),
            @"Cannot override default environments. Environment `_test_env` is a system environment and cannot be overridden."
        );
```

Code after:
            )
            .build();

        let environment =
            Environment::new(DEFAULT_ENV_NAME.to_string(), DEFAULT_ENV_ID.to_string());

        let load_err = RootPackage::<Vanilla>::load(&project.root(), environment, vec![])
            .await
            .unwrap_err();
        assert_snapshot!(
            load_err.to_string(),
            @"Cannot override default environments. Environment `_test_env` is a system environment and cannot be overridden. System environments: _test_env"
        );
    }

    #[test(tokio::test)]
    async fn test_load_and_check_for_env() {
        let (_, root_path) = setup_test_move_project().await;

        let path = root_path.join("graph");
        // should fail as devnet does not exist in the manifest
        assert!(
            RootPackage::<Vanilla>::load(
                &path,
                Environment::new("devnet".to_string(), "abcd1234".to_string()),
                vec![]
            )
            .await
            .is_err()
        );
    }

    /// This just ensures that `RootPackage` does the `rename-from` validation; see
    /// [crate::graph::rename_from::tests] for more detailed tests that operate directly on the
    /// package graph
    #[test(tokio::test)]
    async fn test_rename_from() {
        // `a` depends on `b` which has name `b_name`, but there is no rename-from
        // building the root package should fail because of rename-from validation
        let scenario = TestPackageGraph::new(["a"])
            .add_package("b", |b| b.package_name("b_name"))
            .add_deps([("a", "b")])
            .build();

        RootPackage::<Vanilla>::load(scenario.path_for("a"), default_environment(), vec![])
            .await
            .unwrap_err();
    }

    /// This gives a snapshot of a generated lockfile
    #[test(tokio::test)]