<commit_before>package veille

import (
    "testing"
    "os"
    "io/ioutil"
)

func TestTest_Check(t *testing.T) {
    t.Parallel()
    SetTestLogger(t)

    f, e := ioutil.TempFile("", "veille_test_")
    if e != nil {
        t.Log("Error creating temp file:", e)
        t.FailNow()
    }
    scriptPath := f.Name()
    defer os.Remove(scriptPath)
    f.Write([]byte(`#!/bin/bash
echo '{"status":"ok","message":"message","metrics":{}}'
`))
    f.Chmod(0755)
    f.Close()

    test := Test{
        Functionality: "Some arbitrary action works",
        Script: scriptPath,
    }
    rslt := test.Check()

    switch false {
    case rslt.Status == "ok":
        t.Log("Got wrong status from test script")
        t.FailNow()
    case rslt.Message == "message":
        t.Log("Got wrong message from test script")
        t.FailNow()
    case rslt.T.Functionality == test.Functionality:
        t.Log("Test result populated with wrong test struct")
        t.FailNow()
    }
}

func TestTest_Check_BadJSON(t *testing.T) {
    t.Parallel()
    SetTestLogger(t)

    f, e := ioutil.TempFile("", "veille_test_")
    if e != nil {
        t.Log("Error creating temp file:", e)
        t.FailNow()<commit_msg>Wrote test for missing script file<commit_after>package veille

import (
    "testing"
    "os"
    "io/ioutil"
)

func TestTest_Check(t *testing.T) {
    t.Parallel()
    SetTestLogger(t)

    f, e := ioutil.TempFile("", "veille_test_")
    if e != nil {
        t.Log("Error creating temp file:", e)
        t.FailNow()
    }
    scriptPath := f.Name()
    defer os.Remove(scriptPath)
    f.Write([]byte(`#!/bin/bash
echo '{"status":"ok","message":"message","metrics":{}}'
`))
    f.Chmod(0755)
    f.Close()

    test := Test{
        Functionality: "Some arbitrary action works",
        Script: scriptPath,
    }
    rslt := test.Check()

    switch false {
    case rslt.Status == "ok":
        t.Log("Got wrong status from test script")
        t.FailNow()
    case rslt.Message == "message":
        t.Log("Got wrong message from test script")
        t.FailNow()
    case rslt.T.Functionality == test.Functionality:
        t.Log("Test result populated with wrong test struct")
        t.FailNow()
    }
}

func TestTest_Check_MissingScript(t *testing.T) {
    t.Parallel()
    SetTestLogger(t)

    f, e := ioutil.TempFile("", "veille_test_")
    if e != nil {
        t.Log("Error creating temp file:", e)
        t.FailNow()
    }
    scriptPath := f.Name()
    f.Close()
    os.Remove(scriptPath)

    test := Test{
        Functionality: "Some arbitrary action works",
        Script: scriptPath,
    }
    rslt := test.Check()

    switch false {
    case rslt.Status == "error":
        t.Log("Got wrong status from test script")
        t.FailNow()
    case rslt.T.Functionality == test.Functionality:
        t.Log("Test result populated with wrong test struct")
        t.FailNow()
    }
}

func TestTest_Check_BadJSON(t *testing.T) {
    t.Parallel()
    SetTestLogger(t)

    f, e := ioutil.TempFile("", "veille_test_")
    if e != nil {
        t.Log("Error creating temp file:", e)
        t.FailNow()
{'fraction_non_alphanumeric': 0.15001595914458984, 'fraction_numerical': 0.0025534631343759975, 'mean_word_length': 2.4102285092491837, 'pattern_counts': {'":': 11, '<': 3, '<?xml version=': 0, '>': 3, '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': '6564512', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1054, 'n_words': 250}