konnektoren_core/challenges/informative/
mod.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
5pub struct Informative {
6    /// Unique identifier for the informative content
7    pub id: String,
8    /// Display name of the content
9    pub name: String,
10    /// Description of the content
11    pub description: String,
12    /// Multilingual text content
13    pub text: Vec<InformativeText>,
14}
15
16impl Default for Informative {
17    fn default() -> Self {
18        let data = include_str!("../../../assets/personal_pronouns_info.yml");
19        serde_yaml::from_str(data).unwrap()
20    }
21}
22
23#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
24pub struct InformativeText {
25    /// Language code
26    pub language: String,
27    /// The informative text content
28    pub text: String,
29}
30
31#[cfg(test)]
32mod tests {
33    use super::*;
34
35    #[test]
36    fn from_yaml() {
37        let yaml_data = include_str!("../../../assets/personal_pronouns_info.yml");
38        let dataset: Informative = serde_yaml::from_str(yaml_data).unwrap();
39        assert_eq!(dataset.id, "personal_pronouns_info");
40        assert_eq!(dataset.name, "Personal Pronouns Info");
41    }
42
43    #[test]
44    fn default() {
45        let dataset = Informative::default();
46        assert_eq!(dataset.id, "personal_pronouns_info");
47        assert_eq!(dataset.name, "Personal Pronouns Info");
48    }
49}