<commit_before><commit_msg>Main tests<commit_after>package main

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

func TestMain_fails(t *testing.T) {
	// Returns 1 on bad args
	if code := realMain([]string{}); code != 1 {
		t.Fatalf("bad: %d", code)
	}
	if code := realMain([]string{"1", "2", "3"}); code != 1 {
		t.Fatalf("bad: %d", code)
	}

	// Returns 1 on bad data-dir
	if code := realMain([]string{"consul-migrate", "/unicorns"}); code != 1 {
		t.Fatalf("bad: %d", code)
	}
}

func TestMain_help(t *testing.T) {
	fh, err := ioutil.TempFile("", "consul-migrate")
	if err != nil {
		t.Fatalf("err: %s", err)
	}
	defer os.Remove(fh.Name())

	stdoutOrig := *os.Stdout
	os.Stdout = fh
	defer func() {
		os.Stdout = &stdoutOrig
	}()

	if code := realMain([]string{"consul-migrate", "-h"}); code != 0 {
		t.Fatalf("bad: %d", code)
	}

	if _, err := fh.Seek(0, 0); err != nil {
		t.Fatalf("err: %s", err)
	}
	out, err := ioutil.ReadAll(fh)
	if !strings.HasPrefix(string(out), "Usage:") {
		t.Fatalf("bad: %s", string(out))
	}
}
{'fraction_non_alphanumeric': 0.22643343051506318, 'fraction_numerical': 0.010689990281827016, 'mean_word_length': 3.7247706422018347, 'pattern_counts': {'":': 0, '<': 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': '5776579', 'n_tokens_mistral': 459, 'n_tokens_neox': 442, 'n_words': 98}