<commit_before>package checksum

import (
	m "crypto/md5"
	"github.com/mitchellh/go-homedir"
	"io/ioutil"
	"os"
	"path"
	"testing"
)

func prepareFile() (string, error) {
	file, err := ioutil.TempFile("", "prefix")
	if err != nil {
		return "", err
	}
	if err := ioutil.WriteFile(file.Name(), []byte("some data"), 0600); err != nil {
		return "", err
	}
	return file.Name(), nil
}

func TestTransition(t *testing.T) {
	file, err := prepareFile()
	if err != nil {
		t.Logf("could not create test file: %s", err)
		t.FailNow()
	}
	defer func() {
		err := os.Remove(file)
		if err != nil {
			t.Logf("could not remove test file: %s", err)
		}
	}()

	md5sum, errMD5 := MD5sum(file)
	if errMD5 != nil {
		t.Logf("error calculating old hash: %s", err)
		t.FailNow()
	}
	sum, errSum := Sum(m.New(), file)
	if errSum != nil {
		t.Logf("error calculating new hash: %s", err)
		t.FailNow()
	}
	if md5sum != sum {
		t.Logf("hash mismatch: old [%s] != new [%s]", md5sum, sum)
		t.Fail()
	}
}

func TestSHA256sumFile(t *testing.T) {
	file, err := prepareFile()
	if err != nil {
		t.Logf("could not create test file: %s", err)
		t.FailNow()<commit_msg>feat: remove transition test function<commit_after>package checksum

import (
	"github.com/mitchellh/go-homedir"
	"io/ioutil"
	"os"
	"path"
	"testing"
)

func prepareFile() (string, error) {
	file, err := ioutil.TempFile("", "prefix")
	if err != nil {
		return "", err
	}
	if err := ioutil.WriteFile(file.Name(), []byte("some data"), 0600); err != nil {
		return "", err
	}
	return file.Name(), nil
}

func TestSHA256sumFile(t *testing.T) {
	file, err := prepareFile()
	if err != nil {
		t.Logf("could not create test file: %s", err)
		t.FailNow()
{'fraction_non_alphanumeric': 0.18635014836795252, 'fraction_numerical': 0.012462908011869436, 'mean_word_length': 3.644628099173554, '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': '2309751', 'n_tokens_mistral': 716, 'n_tokens_neox': 680, 'n_words': 177}