use serde::{Deserialize, Serialize};

use crate::prelude::*;

fn default_true() -> bool {
    true
}

fn default_false() -> bool {
    false
}

#[derive(Deserialize, Serialize)]
pub(crate) struct Story {
    #[serde(default = "default_true")]
    pub enabled: bool,
    /// Test case name
    pub name: String,
    /// Name of the function
    pub function: String,
    /// Filename
    pub filename: Option<String>,
    /// Name of the docker image to use ()
    pub docker_image: Option<String>,
    #[serde(default = "default_false")]
    pub expect_failure: bool,
    #[serde(default)]
    pub messages: Vec<Message>,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct JunitConfiguration {
    pub filename: String,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct MarkdownConfiguration {
    pub directory: String,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct ReportGeneratorsConfiguration {
    pub junit: Option<JunitConfiguration>,
    pub markdown: Option<MarkdownConfiguration>,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct Stories {
    /// List of stories
    pub stories: Vec<Story>,
    /// Default filename for the rune script
    pub filename: Option<String>,
    /// Configuration of report generators
    pub report_generators: Option<ReportGeneratorsConfiguration>,
}
