<commit_before>package tests

import (
	"fmt"
	"os"
	"time"

	. "github.com/smartystreets/goconvey/convey"
	"polydawn.net/repeatr/io"
	"polydawn.net/repeatr/io/filter"
	"polydawn.net/repeatr/testutil"
	"polydawn.net/repeatr/testutil/filefixture"
)

func CheckScanWithoutMutation(kind integrity.TransmatKind, transmatFabFn integrity.TransmatFactory) {
	Convey("SPEC: Scanning a filesystem shouldn't change it", testutil.Requires(
		testutil.RequiresRoot,
		func(c C) {
			for _, fixture := range filefixture.All {
				transmat := transmatFabFn("./workdir")
				Convey(fmt.Sprintf("- Fixture %q", fixture.Name), func() {
					// set up fixture
					fixture.Create("./data")
					// scan it with the transmat
					transmat.Scan(kind, "./data", nil, testutil.TestLogger(c))
					// rescan it with the test system
					rescan := filefixture.Scan("./data")
					// should be unchanged<commit_msg>Note on test coverage todos.<commit_after>package tests

import (
	"fmt"
	"os"
	"time"

	. "github.com/smartystreets/goconvey/convey"
	"polydawn.net/repeatr/io"
	"polydawn.net/repeatr/io/filter"
	"polydawn.net/repeatr/testutil"
	"polydawn.net/repeatr/testutil/filefixture"
)

// TODO : surprisingly few of these tests cover actually saving content to a warehouse.
//  While that seems fine within the definitions of the word "scan", and we
//   do have coverage via the round-trip tests, we could do a much better job
//   of testing the commit-to-remote concern as an isolated unit... if we
//   had more APIs around warehouse state inspection.  Big task.  Tackle soon.

func CheckScanWithoutMutation(kind integrity.TransmatKind, transmatFabFn integrity.TransmatFactory) {
	Convey("SPEC: Scanning a filesystem shouldn't change it", testutil.Requires(
		testutil.RequiresRoot,
		func(c C) {
			for _, fixture := range filefixture.All {
				transmat := transmatFabFn("./workdir")
				Convey(fmt.Sprintf("- Fixture %q", fixture.Name), func() {
					// set up fixture
					fixture.Create("./data")
					// scan it with the transmat
					transmat.Scan(kind, "./data", nil, testutil.TestLogger(c))
					// rescan it with the test system
					rescan := filefixture.Scan("./data")
					// should be unchanged
{'fraction_non_alphanumeric': 0.1241442263806481, 'fraction_numerical': 0.0, 'mean_word_length': 3.6244725738396624, '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': '1741628', 'n_tokens_mistral': 813, 'n_tokens_neox': 714, 'n_words': 189}