@@ -26,10 +26,12 @@ type testcase struct {
2626
2727type patchGetter func (tc * testcase ) Patch
2828
29- func TestRFCCases (t * testing.T ) { runCasesFromFile (t , "testdata/tests/rfc.json" , Factorize (), LCS ()) } // https://datatracker.ietf.org/doc/html/rfc6902#appendix-A
30- func TestArrayCases (t * testing.T ) { runCasesFromFile (t , "testdata/tests/array.json" ) }
31- func TestObjectCases (t * testing.T ) { runCasesFromFile (t , "testdata/tests/object.json" ) }
32- func TestRootCases (t * testing.T ) { runCasesFromFile (t , "testdata/tests/root.json" ) }
29+ func TestRFCCases (t * testing.T ) {
30+ runCasesFromFile (t , "testdata/tests/jsonpatch/rfc.json" , Factorize (), LCS ())
31+ } // https://datatracker.ietf.org/doc/html/rfc6902#appendix-A
32+ func TestArrayCases (t * testing.T ) { runCasesFromFile (t , "testdata/tests/jsonpatch/array.json" ) }
33+ func TestObjectCases (t * testing.T ) { runCasesFromFile (t , "testdata/tests/jsonpatch/object.json" ) }
34+ func TestRootCases (t * testing.T ) { runCasesFromFile (t , "testdata/tests/jsonpatch/root.json" ) }
3335
3436func TestDiffer_Reset (t * testing.T ) {
3537 d := & Differ {
@@ -59,28 +61,24 @@ func TestDiffer_Reset(t *testing.T) {
5961}
6062
6163func TestOptions (t * testing.T ) {
62- makeopts := func (opts ... Option ) []Option { return opts }
64+ makeOpts := func (opts ... Option ) []Option { return opts }
6365
6466 for _ , tc := range []struct {
65- testfile string
67+ testFile string
6668 options []Option
6769 }{
68- {"testdata/tests/options/invertible.json" , makeopts (Invertible ())},
69- {"testdata/tests/options/factorization.json" , makeopts (Factorize ())},
70- {"testdata/tests/options/rationalization.json" , makeopts (Rationalize ())},
71- {"testdata/tests/options/equivalence.json" , makeopts (Equivalent ())},
72- {"testdata/tests/options/ignore.json" , makeopts ()},
73- {"testdata/tests/options/lcs.json" , makeopts (LCS (), Factorize ())},
74- {"testdata/tests/options/all.json" , makeopts (Factorize (), Rationalize (), Invertible (), Equivalent ())},
75- {"testdata/tests/options/lcs+equivalence.json" , makeopts (LCS (), Equivalent ())},
70+ {"testdata/tests/jsonpatch/ options/invertible.json" , makeOpts (Invertible ())},
71+ {"testdata/tests/jsonpatch/ options/factorization.json" , makeOpts (Factorize ())},
72+ {"testdata/tests/jsonpatch/ options/rationalization.json" , makeOpts (Rationalize ())},
73+ {"testdata/tests/jsonpatch/ options/equivalence.json" , makeOpts (Equivalent ())},
74+ {"testdata/tests/jsonpatch/ options/ignore.json" , makeOpts ()},
75+ {"testdata/tests/jsonpatch/ options/lcs.json" , makeOpts (LCS (), Factorize ())},
76+ {"testdata/tests/jsonpatch/ options/all.json" , makeOpts (Factorize (), Rationalize (), Invertible (), Equivalent ())},
77+ {"testdata/tests/jsonpatch/ options/lcs+equivalence.json" , makeOpts (LCS (), Equivalent ())},
7678 } {
77- var (
78- ext = filepath .Ext (tc .testfile )
79- base = filepath .Base (tc .testfile )
80- name = strings .TrimSuffix (base , ext )
81- )
79+ name := strings .TrimSuffix (filepath .Base (tc .testFile ), filepath .Ext (tc .testFile ))
8280 t .Run (name , func (t * testing.T ) {
83- runCasesFromFile (t , tc .testfile , tc .options ... )
81+ runCasesFromFile (t , tc .testFile , tc .options ... )
8482 })
8583 }
8684}
@@ -112,12 +110,12 @@ func runTestCases(t *testing.T, cases []testcase, opts ...Option) {
112110 })
113111 if tc .Ignores != nil {
114112 name = fmt .Sprintf ("%s_with_ignore" , name )
115- xopts := append (opts , Ignores (tc .Ignores ... )) //nolint:gocritic
113+ extendedOpts := append (opts , Ignores (tc .Ignores ... )) //nolint:gocritic
116114
117115 t .Run (name , func (t * testing.T ) {
118116 runTestCase (t , tc , func (tc * testcase ) Patch {
119117 return tc .PartialPatch
120- }, xopts ... )
118+ }, extendedOpts ... )
121119 })
122120 }
123121 }
0 commit comments