Skip to content

Commit 8db696f

Browse files
authored
Merge pull request #232 from fredbi/test/testdata-convention
Test/testdata convention
2 parents 4814722 + 89a3c48 commit 8db696f

225 files changed

Lines changed: 105 additions & 82 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.codecov.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ coverage:
77
patch:
88
default:
99
target: 80%
10+
11+
ignore:
12+
- "testdata"
13+
- "internal/antest"
14+
- "internal/testintegration"

‎analyzer_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func TestAnalyzer_All(t *testing.T) {
152152
func TestAnalyzer_DefinitionAnalysis(t *testing.T) {
153153
t.Parallel()
154154

155-
doc := antest.LoadOrFail(t, filepath.Join("fixtures", "definitions.yml"))
155+
doc := antest.LoadOrFail(t, filepath.Join("testdata", "definitions.yml"))
156156

157157
analyzer := New(doc)
158158
definitions := analyzer.allSchemas
@@ -208,7 +208,7 @@ func TestAnalyzer_DefinitionAnalysis(t *testing.T) {
208208
func TestAnalyzer_ReferenceAnalysis(t *testing.T) {
209209
t.Parallel()
210210

211-
doc := antest.LoadOrFail(t, filepath.Join("fixtures", "references.yml"))
211+
doc := antest.LoadOrFail(t, filepath.Join("testdata", "references.yml"))
212212
an := New(doc)
213213

214214
definitions := an.references
@@ -292,7 +292,7 @@ func TestAnalyzer_ReferenceAnalysis(t *testing.T) {
292292
func TestAnalyzer_AllRefsByLocation(t *testing.T) {
293293
t.Parallel()
294294

295-
doc := antest.LoadOrFail(t, filepath.Join("fixtures", "references.yml"))
295+
doc := antest.LoadOrFail(t, filepath.Join("testdata", "references.yml"))
296296
an := New(doc)
297297

298298
byLocation := an.AllRefsByLocation()
@@ -373,7 +373,7 @@ type expectedPattern struct {
373373
func TestAnalyzer_PatternAnalysis(t *testing.T) {
374374
t.Parallel()
375375

376-
doc := antest.LoadOrFail(t, filepath.Join("fixtures", "patterns.yml"))
376+
doc := antest.LoadOrFail(t, filepath.Join("testdata", "patterns.yml"))
377377
an := New(doc)
378378
pt := an.patterns
379379

@@ -760,7 +760,7 @@ func TestAnalyzer_SecurityRequirementsDefinitions(t *testing.T) {
760760
func TestAnalyzer_MoreParamAnalysis(t *testing.T) {
761761
t.Parallel()
762762

763-
bp := filepath.Join("fixtures", "parameters", "fixture-parameters.yaml")
763+
bp := filepath.Join("testdata", "parameters", "fixture-parameters.yaml")
764764
sp := antest.LoadOrFail(t, bp)
765765

766766
an := New(sp)
@@ -873,7 +873,7 @@ func TestAnalyzer_EdgeCases(t *testing.T) {
873873
func TestAnalyzer_EnumAnalysis(t *testing.T) {
874874
t.Parallel()
875875

876-
doc := antest.LoadOrFail(t, filepath.Join("fixtures", "enums.yml"))
876+
doc := antest.LoadOrFail(t, filepath.Join("testdata", "enums.yml"))
877877

878878
an := New(doc)
879879
en := an.enums
@@ -1087,7 +1087,7 @@ func prepareTestParamsValid() *Spec {
10871087
}
10881088

10891089
func prepareTestParamsInvalid(t testing.TB, fixture string) *Spec {
1090-
bp := filepath.Join("fixtures", fixture)
1090+
bp := filepath.Join("testdata", fixture)
10911091
spec := antest.LoadOrFail(t, bp)
10921092

10931093
analyzer := New(spec)

‎diff/spec_analyser_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestDiffForVariousCombinations(t *testing.T) {
2727
require.NotEmpty(t, allTests)
2828

2929
// To filter cases for debugging poke an individual case here eg "path", "enum" etc
30-
// see the test cases in fixtures/diff
30+
// see the test cases in testdata/diff
3131
// Don't forget to remove it once you're done.
3232
// (There's a test at the end to check all cases were run)
3333
matches := allTests
@@ -110,8 +110,8 @@ func makeTestCases(t testing.TB, matches []string) []testCaseData {
110110
}
111111

112112
func TestIssue2962(t *testing.T) {
113-
oldSpec := filepath.Join("fixtures", "bugs", "2962", "old.json")
114-
newSpec := filepath.Join("fixtures", "bugs", "2962", "new.json")
113+
oldSpec := filepath.Join("testdata", "bugs", "2962", "old.json")
114+
newSpec := filepath.Join("testdata", "bugs", "2962", "new.json")
115115

116116
t.Run("should diff", func(t *testing.T) {
117117
diffs, err := getDiffs(oldSpec, newSpec)
@@ -130,7 +130,7 @@ func TestIssue2962(t *testing.T) {
130130
}
131131

132132
func fixturePath(file string, parts ...string) string {
133-
return filepath.Join("fixtures", strings.Join(append([]string{file}, parts...), ""))
133+
return filepath.Join("testdata", strings.Join(append([]string{file}, parts...), ""))
134134
}
135135

136136
type testCaseData struct {

0 commit comments

Comments
 (0)
⌂ 换网址