From f3e93347bea5545e22ca2ded629a06dae74bdae2 Mon Sep 17 00:00:00 2001 From: gkampitakis Date: Thu, 2 Nov 2023 20:50:16 +0000 Subject: [PATCH] feat: support sort snaps on clean --- README.md | 23 +-- go.mod | 4 +- go.sum | 4 + snaps/clean.go | 116 +++++++++--- snaps/clean_test.go | 251 +++++++++++++++---------- snaps/testdata/mock-snap-1 | 22 +++ snaps/testdata/mock-snap-2 | 20 ++ snaps/testdata/mock-snap-sort-1 | 45 +++++ snaps/testdata/mock-snap-sort-1-sorted | 45 +++++ snaps/testdata/mock-snap-sort-2 | 42 +++++ snaps/testdata/mock-snap-sort-2-sorted | 42 +++++ 11 files changed, 479 insertions(+), 135 deletions(-) create mode 100644 snaps/testdata/mock-snap-1 create mode 100644 snaps/testdata/mock-snap-2 create mode 100644 snaps/testdata/mock-snap-sort-1 create mode 100644 snaps/testdata/mock-snap-sort-1-sorted create mode 100644 snaps/testdata/mock-snap-sort-2 create mode 100644 snaps/testdata/mock-snap-sort-2-sorted diff --git a/README.md b/README.md index a7a81c5..a18f3b3 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ - [Configuration](#configuration) - [Update Snapshots](#update-snapshots) - [Clean obsolete Snapshots](#clean-obsolete-snapshots) + - [Sort Snapshots](#sort-snapshots) - [Skipping Tests](#skipping-tests) - [Running tests on CI](#running-tests-on-ci) - [No Color](#no-color) @@ -271,6 +272,10 @@ func TestMain(t *testing.M) { For more information around [TestMain](https://pkg.go.dev/testing#hdr-Main). +### Sort Snapshots + +TBD + ### Skipping Tests If you want to skip one test using `t.Skip`, `go-snaps` can't keep track @@ -322,7 +327,8 @@ map[string]interface {}{ --- ``` -> `*.snap` files are not meant to be edited manually, this might cause unexpected results. +> [!NOTE] +> If your snapshot data contain characters `---` at the start of a line followed by a new line, `go-snaps` will "escape" them and save them as `/-/-/-/` to differentiate them from termination characters. ## Acknowledgments @@ -332,15 +338,10 @@ This library used [Jest Snapshoting](https://jestjs.io/docs/snapshot-testing) an - Cupaloy is a great and simple Golang snapshoting solution. - The [logo](https://github.com/MariaLetta/free-gophers-pack) was made by [MariaLetta](https://github.com/MariaLetta). -## Notes - -1. ⚠️ When running a specific test file by specifying a path - `go test ./my_test.go`, `go-snaps` can't track the path so it will mistakenly mark snapshots as obsolete. - -2. The order in which tests are written might not be the same order that snapshots are saved in the file. +## Appendix -3. If your snapshot data contain the termination characters `---` at the start of a line - and after a new line, `go-snaps` will "escape" them and save them as `/-/-/-/`. This - should not cause any diff issues (false-positives). +> [!WARNING] +> When running a specific test file by specifying a path `go test ./my_test.go`, `go-snaps` can't track the path so it will mistakenly mark snapshots as obsolete. -4. Snapshots should be treated as code. The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process +> [!IMPORTANT] +> Snapshots should be treated as code. The snapshot artifact should be committed alongside code changes, and reviewed as part of your code review process diff --git a/go.mod b/go.mod index 2276bf7..4a21ce1 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/gkampitakis/go-snaps go 1.21.0 require ( - github.com/gkampitakis/ciinfo v0.2.5 + github.com/gkampitakis/ciinfo v0.3.0 github.com/gkampitakis/go-diff v1.3.2 github.com/kr/pretty v0.3.1 - github.com/tidwall/gjson v1.16.0 + github.com/tidwall/gjson v1.17.0 github.com/tidwall/pretty v1.2.1 github.com/tidwall/sjson v1.2.5 ) diff --git a/go.sum b/go.sum index c9aa061..a303126 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/gkampitakis/ciinfo v0.2.5 h1:K0mac90lGguc1conc46l0YEsB7/nioWCqSnJp/6z8Eo= github.com/gkampitakis/ciinfo v0.2.5/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= +github.com/gkampitakis/ciinfo v0.3.0 h1:gWZlOC2+RYYttL0hBqcoQhM7h1qNkVqvRCV1fOvpAv8= +github.com/gkampitakis/ciinfo v0.3.0/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M= github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -14,6 +16,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg= github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= diff --git a/snaps/clean.go b/snaps/clean.go index 9c7d685..46fc127 100644 --- a/snaps/clean.go +++ b/snaps/clean.go @@ -7,7 +7,7 @@ import ( "io" "os" "path/filepath" - "regexp" + "slices" "strings" "sync" "testing" @@ -17,8 +17,7 @@ import ( // Matches [ Test... - number ] testIDs var ( - testIDRegexp = regexp.MustCompile(`(?m)^\[(Test.* - \d+)\]$`) - testEvents = newTestEvents() + testEvents = newTestEvents() ) const ( @@ -46,6 +45,11 @@ func newTestEvents() *events { } } +type CleanOpts struct { + // If set to true, `go-snaps` will sort the snapshots + Sort bool +} + // Clean runs checks for identifying obsolete snapshots and prints a Test Summary. // // Must be called in a TestMain @@ -58,13 +62,34 @@ func newTestEvents() *events { // // os.Exit(v) // } -func Clean(t *testing.M) { +// +// Clean also supports options for sorting the snapshots +// +// func TestMain(t *testing.M) { +// v := t.Run() +// +// // After all tests have run `go-snaps` can check for not used snapshots +// snaps.Clean(t, snaps.CleanOpts{Sort: true}) +// +// os.Exit(v) +// } +func Clean(t *testing.M, opts ...CleanOpts) { + var opt CleanOpts + if len(opts) != 0 { + opt = opts[0] + } // This is just for making sure Clean is called from TestMain _ = t runOnly := flag.Lookup("test.run").Value.String() obsoleteFiles, usedFiles := examineFiles(testsRegistry.values, runOnly, shouldClean) - obsoleteTests, err := examineSnaps(testsRegistry.values, usedFiles, runOnly, shouldClean) + obsoleteTests, err := examineSnaps( + testsRegistry.values, + usedFiles, + runOnly, + shouldClean, + opt.Sort, + ) if err != nil { fmt.Println(err) return @@ -80,6 +105,25 @@ func Clean(t *testing.M) { } } +// getTestID will return the testID if the line is in the form of [Test... - number] +func getTestID(b []byte) (string, bool) { + if len(b) == 0 { + return "", false + } + + if bytes.Equal(b[0:5], []byte("[Test")) && b[len(b)-1] == ']' { + for i := len(b) - 2; i >= 4; i-- { + if b[i] == ' ' && b[i-1] == '-' && b[i-2] == ' ' { + return string(b[1 : len(b)-1]), true + } + } + + return "", false + } + + return "", false +} + /* Map containing the occurrences is checked against the filesystem. @@ -139,20 +183,19 @@ func examineSnaps( used []string, runOnly string, shouldUpdate bool, + sort bool, ) ([]string, error) { obsoleteTests := []string{} + tests := map[string]string{} + data := bytes.Buffer{} + testIDs := []string{} for _, snapPath := range used { f, err := os.OpenFile(snapPath, os.O_RDWR, os.ModePerm) if err != nil { return nil, err } - defer f.Close() - var updatedFile bytes.Buffer - if i, err := f.Stat(); err == nil { - updatedFile.Grow(int(i.Size())) - } var hasDiffs bool registeredTests := occurrences(registry[snapPath]) @@ -161,33 +204,32 @@ func examineSnaps( for s.Scan() { b := s.Bytes() // Check if line is a test id - match := testIDRegexp.FindSubmatch(b) - if len(match) <= 1 { + testID, match := getTestID(b) + if !match { continue } - testID := string(match[1]) + testIDs = append(testIDs, testID) if !registeredTests.Has(testID) && !testSkipped(testID, runOnly) { obsoleteTests = append(obsoleteTests, testID) hasDiffs = true removeSnapshot(s) - continue } - updatedFile.WriteByte('\n') - updatedFile.Write(b) - updatedFile.WriteByte('\n') - for s.Scan() { line := s.Bytes() - updatedFile.Write(line) - updatedFile.WriteByte('\n') if bytes.Equal(line, endSequenceByteSlice) { + tests[testID] = data.String() + + data.Reset() break } + + data.Write(line) + data.WriteByte('\n') } } @@ -195,13 +237,41 @@ func examineSnaps( return nil, err } - if !hasDiffs || !shouldUpdate { + isSorted := slices.IsSorted(testIDs) + + // If there are no diffs or we don't want to update the snaps + // and if we don't want to sort the snaps or they are already sorted we skip + if (!hasDiffs || !shouldUpdate) && (!sort || isSorted) { + f.Close() + + clear(tests) + testIDs = testIDs[:0] + data.Reset() + continue } - if err = overwriteFile(f, updatedFile.Bytes()); err != nil { - fmt.Println(err) + if sort && !isSorted { + slices.Sort(testIDs) } + + if err := overwriteFile(f, nil); err != nil { + return nil, err + } + + for _, id := range testIDs { + test, ok := tests[id] + if !ok { + continue + } + + fmt.Fprintf(f, "\n[%s]\n%s%s\n", id, test, endSequence) + } + f.Close() + + clear(tests) + testIDs = testIDs[:0] + data.Reset() } return obsoleteTests, nil diff --git a/snaps/clean_test.go b/snaps/clean_test.go index dbec908..281b98b 100644 --- a/snaps/clean_test.go +++ b/snaps/clean_test.go @@ -2,6 +2,7 @@ package snaps import ( "errors" + "fmt" "os" "path/filepath" "sort" @@ -10,58 +11,21 @@ import ( "github.com/gkampitakis/go-snaps/internal/test" ) -const mockSnap1 = ` - -[TestDir1_1/TestSimple - 1] - -int(1) - -string hello world 1 1 1 - ---- - -[TestDir1_2/TestSimple - 1] -int(10) -string hello world 1 2 1 ---- - -[TestDir1_3/TestSimple - 1] -int(100) -string hello world 1 3 1 ---- - -[TestDir1_3/TestSimple - 2] -int(1000) -string hello world 1 3 2 ---- - -` - -const mockSnap2 = ` - -[TestDir2_1/TestSimple - 1] -int(1) -string hello world 2 1 1 ---- - -[TestDir2_1/TestSimple - 2] -int(10) -string hello world 2 1 2 ---- - -[TestDir2_1/TestSimple - 3] -int(100) -string hello world 2 1 3 ---- - -[TestDir2_2/TestSimple - 1] -int(1000) -string hello world 2 2 1 ---- +// loadMockSnap loads a mock snap from the testdata directory +func loadMockSnap(t *testing.T, name string) []byte { + t.Helper() + snap, err := os.ReadFile(fmt.Sprintf("testdata/%s", name)) + if err != nil { + t.Fatal(err) + } -` + return snap +} -func setupTempExamineFiles(t *testing.T) (map[string]map[string]int, string, string) { +func setupTempExamineFiles( + t *testing.T, + mockSnap1, mockSnap2 []byte, +) (map[string]map[string]int, string, string) { t.Helper() dir1 := t.TempDir() dir2 := t.TempDir() @@ -72,11 +36,11 @@ func setupTempExamineFiles(t *testing.T) (map[string]map[string]int, string, str }{ { name: filepath.FromSlash(dir1 + "/test1.snap"), - data: []byte(mockSnap1), + data: mockSnap1, }, { name: filepath.FromSlash(dir2 + "/test2.snap"), - data: []byte(mockSnap2), + data: mockSnap2, }, { name: filepath.FromSlash(dir1 + "/obsolete1.snap"), @@ -104,10 +68,16 @@ func setupTempExamineFiles(t *testing.T) (map[string]map[string]int, string, str "TestDir1_1/TestSimple": 1, "TestDir1_2/TestSimple": 1, "TestDir1_3/TestSimple": 2, + "TestCat": 1, + "TestAlpha": 2, + "TestBeta": 1, }, files[1].name: { "TestDir2_1/TestSimple": 3, "TestDir2_2/TestSimple": 1, + "TestCat": 1, + "TestAlpha": 2, + "TestBeta": 1, }, } @@ -116,7 +86,11 @@ func setupTempExamineFiles(t *testing.T) (map[string]map[string]int, string, str func TestExamineFiles(t *testing.T) { t.Run("should parse files", func(t *testing.T) { - tests, dir1, dir2 := setupTempExamineFiles(t) + tests, dir1, dir2 := setupTempExamineFiles( + t, + loadMockSnap(t, "mock-snap-1"), + loadMockSnap(t, "mock-snap-2"), + ) obsolete, used := examineFiles(tests, "", false) obsoleteExpected := []string{ @@ -140,7 +114,11 @@ func TestExamineFiles(t *testing.T) { t.Run("should remove outdate files", func(t *testing.T) { shouldUpdate := true - tests, dir1, dir2 := setupTempExamineFiles(t) + tests, dir1, dir2 := setupTempExamineFiles( + t, + loadMockSnap(t, "mock-snap-1"), + loadMockSnap(t, "mock-snap-2"), + ) examineFiles(tests, "", shouldUpdate) if _, err := os.Stat(filepath.FromSlash(dir1 + "/obsolete1.snap")); !errors.Is( @@ -161,21 +139,27 @@ func TestExamineFiles(t *testing.T) { func TestExamineSnaps(t *testing.T) { t.Run("should report no obsolete snapshots", func(t *testing.T) { - tests, dir1, dir2 := setupTempExamineFiles(t) + tests, dir1, dir2 := setupTempExamineFiles( + t, + loadMockSnap(t, "mock-snap-1"), + loadMockSnap(t, "mock-snap-2"), + ) used := []string{ filepath.FromSlash(dir1 + "/test1.snap"), filepath.FromSlash(dir2 + "/test2.snap"), } shouldUpdate := false - obsolete, err := examineSnaps(tests, used, "", shouldUpdate) + obsolete, err := examineSnaps(tests, used, "", shouldUpdate, false) test.Equal(t, []string{}, obsolete) test.NoError(t, err) }) t.Run("should report two obsolete snapshots and not change content", func(t *testing.T) { - tests, dir1, dir2 := setupTempExamineFiles(t) + mockSnap1 := loadMockSnap(t, "mock-snap-1") + mockSnap2 := loadMockSnap(t, "mock-snap-2") + tests, dir1, dir2 := setupTempExamineFiles(t, mockSnap1, mockSnap2) used := []string{ filepath.FromSlash(dir1 + "/test1.snap"), filepath.FromSlash(dir2 + "/test2.snap"), @@ -187,7 +171,7 @@ func TestExamineSnaps(t *testing.T) { // Removing the test entirely delete(tests[used[1]], "TestDir2_2/TestSimple") - obsolete, err := examineSnaps(tests, used, "", shouldUpdate) + obsolete, err := examineSnaps(tests, used, "", shouldUpdate, false) content1 := test.GetFileContent(t, used[0]) content2 := test.GetFileContent(t, used[1]) @@ -195,37 +179,43 @@ func TestExamineSnaps(t *testing.T) { test.NoError(t, err) // Content of snaps is not changed - test.Equal(t, mockSnap1, content1) - test.Equal(t, mockSnap2, content2) + test.Equal(t, mockSnap1, []byte(content1)) + test.Equal(t, mockSnap2, []byte(content2)) }) t.Run("should update the obsolete snap files", func(t *testing.T) { - tests, dir1, dir2 := setupTempExamineFiles(t) + tests, dir1, dir2 := setupTempExamineFiles( + t, + loadMockSnap(t, "mock-snap-1"), + loadMockSnap(t, "mock-snap-2"), + ) used := []string{ filepath.FromSlash(dir1 + "/test1.snap"), filepath.FromSlash(dir2 + "/test2.snap"), } shouldUpdate := true + // removing tests from the map means those tests are no longer used delete(tests[used[0]], "TestDir1_3/TestSimple") delete(tests[used[1]], "TestDir2_1/TestSimple") - obsolete, err := examineSnaps(tests, used, "", shouldUpdate) + obsolete, err := examineSnaps(tests, used, "", shouldUpdate, false) content1 := test.GetFileContent(t, used[0]) content2 := test.GetFileContent(t, used[1]) + // !!unsorted expected1 := ` +[TestDir1_2/TestSimple - 1] +int(10) +string hello world 1 2 1 +--- + [TestDir1_1/TestSimple - 1] int(1) string hello world 1 1 1 ---- - -[TestDir1_2/TestSimple - 1] -int(10) -string hello world 1 2 1 --- ` expected2 := ` @@ -239,8 +229,8 @@ string hello world 2 2 1 "TestDir1_3/TestSimple - 1", "TestDir1_3/TestSimple - 2", "TestDir2_1/TestSimple - 1", - "TestDir2_1/TestSimple - 2", "TestDir2_1/TestSimple - 3", + "TestDir2_1/TestSimple - 2", }, obsolete, ) @@ -250,6 +240,73 @@ string hello world 2 2 1 test.Equal(t, expected1, content1) test.Equal(t, expected2, content2) }) + + t.Run("should sort all tests", func(t *testing.T) { + mockSnap1 := loadMockSnap(t, "mock-snap-sort-1") + mockSnap2 := loadMockSnap(t, "mock-snap-sort-2") + expectedMockSnap1 := loadMockSnap(t, "mock-snap-sort-1-sorted") + expectedMockSnap2 := loadMockSnap(t, "mock-snap-sort-2-sorted") + tests, dir1, dir2 := setupTempExamineFiles( + t, + mockSnap1, + mockSnap2, + ) + used := []string{ + filepath.FromSlash(dir1 + "/test1.snap"), + filepath.FromSlash(dir2 + "/test2.snap"), + } + + obsolete, err := examineSnaps(tests, used, "", false, true) + + test.NoError(t, err) + test.Equal(t, 0, len(obsolete)) + + content1 := test.GetFileContent(t, filepath.FromSlash(dir1+"/test1.snap")) + content2 := test.GetFileContent(t, filepath.FromSlash(dir2+"/test2.snap")) + + test.Equal(t, string(expectedMockSnap1), content1) + test.Equal(t, string(expectedMockSnap2), content2) + }) + + t.Run( + "should not update file if snaps are already sorted and shouldUpdate=false", + func(t *testing.T) { + mockSnap1 := loadMockSnap(t, "mock-snap-sort-1-sorted") + mockSnap2 := loadMockSnap(t, "mock-snap-sort-2-sorted") + tests, dir1, dir2 := setupTempExamineFiles( + t, + mockSnap1, + mockSnap2, + ) + used := []string{ + filepath.FromSlash(dir1 + "/test1.snap"), + filepath.FromSlash(dir2 + "/test2.snap"), + } + + // removing tests from the map means those tests are no longer used + delete(tests[used[0]], "TestDir1_3/TestSimple") + delete(tests[used[1]], "TestDir2_1/TestSimple") + + obsolete, err := examineSnaps(tests, used, "", false, true) + + test.NoError(t, err) + test.Equal(t, []string{ + "TestDir1_3/TestSimple - 1", + "TestDir1_3/TestSimple - 2", + "TestDir2_1/TestSimple - 1", + "TestDir2_1/TestSimple - 2", + "TestDir2_1/TestSimple - 3", + }, + obsolete, + ) + + content1 := test.GetFileContent(t, filepath.FromSlash(dir1+"/test1.snap")) + content2 := test.GetFileContent(t, filepath.FromSlash(dir2+"/test2.snap")) + + test.Equal(t, string(mockSnap1), content1) + test.Equal(t, string(mockSnap2), content2) + }, + ) } func TestOccurrences(t *testing.T) { @@ -341,40 +398,36 @@ func TestSummary(t *testing.T) { } } -func TestTestIDRegex(t *testing.T) { - for _, tc := range []struct { - input string - id string - matched bool +func TestGetTestID(t *testing.T) { + testCases := []struct { + input string + expectedID string + valid bool }{ - { - input: "[Test/something - 10]", - id: "Test/something - 10", - matched: true, - }, - { - // must have [ - input: "Test/something - 10]", - matched: false, - }, - { - // must have Test at the start - input: "[Tes/something - 10]", - matched: false, - }, - { - // must have dash between test name and number - input: "[Test something 10]", - matched: false, - }, - } { + {"[Test123 - Some Test]", "Test123 - Some Test", true}, + {"", "", false}, + {"Invalid input", "", false}, + {"[Test - Missing Closing Bracket", "", false}, + {"[TesGetTestID- No Space]", "", false}, + {"[Test/something - 10]", "Test/something - 10", true}, + // // must have [ + {"Test something 10]", "", false}, + // must have Test at the start + {"TesGetTestID - ]", "", false}, + // must have dash between test name and number + {"[Test something 10]", "", false}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.input, func(t *testing.T) { - if tc.matched { - test.Equal(t, tc.id, testIDRegexp.FindStringSubmatch(tc.input)[1]) - return - } + t.Parallel() + + id, ok := getTestID([]byte(tc.input)) - test.Equal(t, 0, len(testIDRegexp.FindStringSubmatch(tc.input))) + test.Equal(t, tc.valid, ok) + test.Equal(t, tc.expectedID, id) }) } } diff --git a/snaps/testdata/mock-snap-1 b/snaps/testdata/mock-snap-1 new file mode 100644 index 0000000..992fba8 --- /dev/null +++ b/snaps/testdata/mock-snap-1 @@ -0,0 +1,22 @@ +[TestDir1_3/TestSimple - 1] +int(100) +string hello world 1 3 1 +--- + +[TestDir1_2/TestSimple - 1] +int(10) +string hello world 1 2 1 +--- + +[TestDir1_3/TestSimple - 2] +int(1000) +string hello world 1 3 2 +--- + +[TestDir1_1/TestSimple - 1] + +int(1) + +string hello world 1 1 1 + +--- diff --git a/snaps/testdata/mock-snap-2 b/snaps/testdata/mock-snap-2 new file mode 100644 index 0000000..6a3c0ed --- /dev/null +++ b/snaps/testdata/mock-snap-2 @@ -0,0 +1,20 @@ + +[TestDir2_2/TestSimple - 1] +int(1000) +string hello world 2 2 1 +--- + +[TestDir2_1/TestSimple - 1] +int(1) +string hello world 2 1 1 +--- + +[TestDir2_1/TestSimple - 3] +int(100) +string hello world 2 1 3 +--- + +[TestDir2_1/TestSimple - 2] +int(10) +string hello world 2 1 2 +--- diff --git a/snaps/testdata/mock-snap-sort-1 b/snaps/testdata/mock-snap-sort-1 new file mode 100644 index 0000000..6364be0 --- /dev/null +++ b/snaps/testdata/mock-snap-sort-1 @@ -0,0 +1,45 @@ + +[TestDir1_1/TestSimple - 1] + +int(1) + +string hello world 1 1 1 + +--- + +[TestCat - 1] +string("") +--- + +[TestAlpha - 2] +mock snapshot second value +--- + +[TestDir1_2/TestSimple - 1] +int(10) +string hello world 1 2 1 +--- + +[TestBeta - 1] +mock snapshot +and + +another + +value + +--- + +[TestDir1_3/TestSimple - 1] +int(100) +string hello world 1 3 1 +--- + +[TestDir1_3/TestSimple - 2] +int(1000) +string hello world 1 3 2 +--- + +[TestAlpha - 1] +mock snapshot +--- diff --git a/snaps/testdata/mock-snap-sort-1-sorted b/snaps/testdata/mock-snap-sort-1-sorted new file mode 100644 index 0000000..4d579b4 --- /dev/null +++ b/snaps/testdata/mock-snap-sort-1-sorted @@ -0,0 +1,45 @@ + +[TestAlpha - 1] +mock snapshot +--- + +[TestAlpha - 2] +mock snapshot second value +--- + +[TestBeta - 1] +mock snapshot +and + +another + +value + +--- + +[TestCat - 1] +string("") +--- + +[TestDir1_1/TestSimple - 1] + +int(1) + +string hello world 1 1 1 + +--- + +[TestDir1_2/TestSimple - 1] +int(10) +string hello world 1 2 1 +--- + +[TestDir1_3/TestSimple - 1] +int(100) +string hello world 1 3 1 +--- + +[TestDir1_3/TestSimple - 2] +int(1000) +string hello world 1 3 2 +--- diff --git a/snaps/testdata/mock-snap-sort-2 b/snaps/testdata/mock-snap-sort-2 new file mode 100644 index 0000000..665870c --- /dev/null +++ b/snaps/testdata/mock-snap-sort-2 @@ -0,0 +1,42 @@ + +[TestAlpha - 1] +mock snapshot +--- + +[TestBeta - 1] +mock snapshot +and + +another + +value + +--- + +[TestDir2_1/TestSimple - 1] +int(1) +string hello world 2 1 1 +--- + +[TestDir2_2/TestSimple - 1] +int(1000) +string hello world 2 2 1 +--- + +[TestDir2_1/TestSimple - 2] +int(10) +string hello world 2 1 2 +--- + +[TestDir2_1/TestSimple - 3] +int(100) +string hello world 2 1 3 +--- + +[TestCat - 1] +string("") +--- + +[TestAlpha - 2] +mock snapshot second value +--- diff --git a/snaps/testdata/mock-snap-sort-2-sorted b/snaps/testdata/mock-snap-sort-2-sorted new file mode 100644 index 0000000..3afaecc --- /dev/null +++ b/snaps/testdata/mock-snap-sort-2-sorted @@ -0,0 +1,42 @@ + +[TestAlpha - 1] +mock snapshot +--- + +[TestAlpha - 2] +mock snapshot second value +--- + +[TestBeta - 1] +mock snapshot +and + +another + +value + +--- + +[TestCat - 1] +string("") +--- + +[TestDir2_1/TestSimple - 1] +int(1) +string hello world 2 1 1 +--- + +[TestDir2_1/TestSimple - 2] +int(10) +string hello world 2 1 2 +--- + +[TestDir2_1/TestSimple - 3] +int(100) +string hello world 2 1 3 +--- + +[TestDir2_2/TestSimple - 1] +int(1000) +string hello world 2 2 1 +---