Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Test With The Same Name As A Function Error Message

This is what it looks like when I made a test that had the same name as the function I was trying to test.

code full

This is what my code looked like

rust
fn get_initial_template(page: &Page) -> Result<String, String> {
  Ok("a bunch of actual stuff here".to_string()
}


#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn get_initial_template() {
        let page = Page::builder_with_source();
        let left = Ok("asdf".to_string());
        let right = get_initial_template(&page);
        assert_eq!(left, right);
    }
}

The thing that threw me was the message saying the function expected zero arguments but I was passing one. That's because the test function doesn't take arguments even though my actual function does. That's what finally led me to figure out what was up.

The solution was to rename the test function to something else (e.g. [TODO: Code shorthand span ] )