<commit_before>#[macro_use]
extern crate serde_elm;

use std::env;
use std::fs::File;
use std::io::{Read, Error};
use std::path::Path;

#[allow(dead_code)]
#[derive(Elm)]
struct Simple {
    name: String
}

#[test]
fn should_assert_elm_generation_was_done() {
	let root = env::current_dir().unwrap();
    let mut path = root.clone();
    path.push("generated");
    path.push("Simple.elm");

    assert!(path.exists());
    assert!(path.is_file());

    let actual = contents_of(&path).unwrap();

    let mut expected_path = root.clone();
    expected_path.push("tests");
    expected_path.push("assets");
    expected_path.push("Simple.test.elm");

    let expected = contents_of(&expected_path).unwrap();

    assert_eq!(actual, expected);
}

fn contents_of(path: &Path) -> Result<String, Error> {
    let mut file = File::open(path)?;
    let mut content = String::new();
    file.read_to_string(&mut content)?;

    Ok(content)
}<commit_msg>Make content check accept a model name<commit_after>#[macro_use]
extern crate serde_elm;

use std::env;
use std::fs::File;
use std::io::{Read, Error};
use std::path::Path;

#[allow(dead_code)]
#[derive(Elm)]
struct Simple {
    name: String
}

#[test]
fn should_assert_elm_generation_was_done() {
	let model_name = "Simple";
	assert!(content_equal_for(model_name))
}

fn content_equal_for<S>(model_name: S) -> bool where S: Into<String> {
	let model_name = model_name.into();
	let root = env::current_dir().unwrap();
    let mut path = root.clone();
    path.push("generated");
    path.push(format!("{}.elm", model_name));

    assert!(path.exists());
    assert!(path.is_file());

    let actual = contents_of(&path).unwrap();

    let mut expected_path = root.clone();
    expected_path.push("tests");
    expected_path.push("assets");
    expected_path.push(format!("{}.test.elm", model_name));

    let expected = contents_of(&expected_path).unwrap();

    actual == expected
}

fn contents_of(path: &Path) -> Result<String, Error> {
    let mut file = File::open(path)?;
    let mut content = String::new();
    file.read_to_string(&mut content)?;

    Ok(content)
}
{'fraction_non_alphanumeric': 0.17430325932923948, 'fraction_numerical': 0.0, 'mean_word_length': 4.559055118110236, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4786911', 'n_tokens_mistral': 716, 'n_tokens_neox': 720, 'n_words': 150}