The problem is demonstrated by the following comment —
//! let expected = "# HELP my_counter This is my counter.\n".to_owned() +
//! "# TYPE my_counter counter\n" +
//! "my_counter_total 1\n" +
//! "# EOF\n";
The HELP and TYPE lines should use my_counter_total, not my_counter.