Repository: block/goose
File: crates/goose-mcp/src/developer/rmcp_developer.rs (Rust)

Code before:
        let temp_dir = tempfile::tempdir().unwrap();
        std::env::set_current_dir(&temp_dir).unwrap();

        // Don't create any ignore files
        let server = create_test_server();

        // Default patterns should be used
        assert!(
            server.is_ignored(Path::new(".env")),
            ".env should be ignored by default patterns"
        );
        assert!(
            server.is_ignored(Path::new(".env.local")),
            ".env.local should be ignored by default patterns"
        );
        assert!(
            server.is_ignored(Path::new("secrets.txt")),
            "secrets.txt should be ignored by default patterns"
        );
        assert!(
            !server.is_ignored(Path::new("normal.txt")),
            "normal.txt should not be ignored"
        );
    }

    /// Test case for gooseignore patterns
    struct GooseignoreTestCase {
        name: &'static str,
        global_ignore: Option<&'static str>,
        local_ignore: Option<&'static str>,
        /// (path, expected_ignored)
        expected: &'static [(&'static str, bool)],
    }

    #[test]
    #[serial]
    #[cfg(unix)] // Uses HOME env var which is Unix-specific; Windows uses APPDATA/LOCALAPPDATA
    fn test_gooseignore_patterns() {
        let test_cases = [
            GooseignoreTestCase {
                name: "global negation pattern",
                global_ignore: Some("!.env.example\n"),
                local_ignore: None,
                expected: &[
                    (".env", true),
                    (".env.local", true),
                    (".env.example", false),
                ],
            },
            GooseignoreTestCase {
                name: "local overrides global",

Review comment (suggestion):
Sorry, this still ended up being pretty complicated; I was hoping we could have something that just tested some of the diff cases without actually interacting with the filesystem. 

If that's not possible, let's just get rid of the test completely because the logic in build_ignore_patterns isn't too heavy. 

Code after:
        let temp_dir = tempfile::tempdir().unwrap();
        std::env::set_current_dir(&temp_dir).unwrap();

        // Don't create any ignore files
        let server = create_test_server();

        // Default patterns should be used
        assert!(
            server.is_ignored(Path::new(".env")),
            ".env should be ignored by default patterns"
        );
        assert!(
            server.is_ignored(Path::new(".env.local")),
            ".env.local should be ignored by default patterns"
        );
        assert!(
            server.is_ignored(Path::new("secrets.txt")),
            "secrets.txt should be ignored by default patterns"
        );
        assert!(
            !server.is_ignored(Path::new("normal.txt")),
            "normal.txt should not be ignored"
        );
    }

    #[test]
    #[serial]
    fn test_resolve_path_absolute() {
        let temp_dir = tempfile::tempdir().unwrap();
        std::env::set_current_dir(&temp_dir).unwrap();

        let server = create_test_server();
        let absolute_path = temp_dir.path().join("test.txt");
        let absolute_path_str = absolute_path.to_str().unwrap();

        let resolved = server.resolve_path(absolute_path_str).unwrap();
        assert_eq!(resolved, absolute_path);
    }

    #[tokio::test]
    #[serial]
    async fn test_resolve_path_relative() {
        let temp_dir = tempfile::tempdir().unwrap();
        std::env::set_current_dir(&temp_dir).unwrap();

        let server = create_test_server();
        let relative_path = "subdir/test.txt";

        let resolved = server.resolve_path(relative_path).unwrap();
        let expected = std::env::current_dir().unwrap().join("subdir/test.txt");
        assert_eq!(resolved, expected);