overcast 0.1.3

Strongly typed changelogs for projects as changeable as the weather
Documentation
use crate::Changelog;

/// Render a changelog into a JSON string representation
pub fn render_json(changelog: &Changelog) -> Result<String, serde_json::Error> {
    serde_json::to_string_pretty(changelog)
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::get_overcast_changelog;
    use expect_test::expect;

    #[test]
    fn test_render_changelog() {
        let changelog = get_overcast_changelog();

        let json = render_json(&changelog).unwrap();

        expect![[r#"
            {
              "title": "Overcast",
              "description": "Statically typed changelogs for projects as changeable as the weather",
              "releases": {
                "0.1.0": {
                  "summary": "Initial Release of Overcast",
                  "version": "0.1.0",
                  "added": [
                    {
                      "description": "Basic Keep A Changelog structure",
                      "ticket_id": null
                    },
                    {
                      "description": "Example to render Overcast's changelog",
                      "ticket_id": null
                    },
                    {
                      "description": "Markdown rendering",
                      "ticket_id": null
                    }
                  ],
                  "changed": [],
                  "deprecated": [],
                  "removed": [],
                  "fixed": [],
                  "security": [],
                  "yanked": false,
                  "date": "2024-03-19"
                }
              },
              "keep_a_changelog_message": true,
              "semantic_versioning_message": true
            }"#]].assert_eq(&json);
    }
}