Skip to content

Commit

Permalink
chore: refactor onlyModels tests
Browse files Browse the repository at this point in the history
  • Loading branch information
omissis committed Oct 5, 2023
1 parent 49e0547 commit 925fe1f
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 49 deletions.
75 changes: 75 additions & 0 deletions tests/data/misc/onlyModels/onlyModels.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
28 changes: 0 additions & 28 deletions tests/data/onlyModels/onlyModel.go

This file was deleted.

42 changes: 21 additions & 21 deletions tests/generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ func TestCrossPackageNoOutput(t *testing.T) {
testExampleFile(t, cfg, "./data/crossPackageNoOutput/schema/schema.json")
}

func TestSpecialCharacters(t *testing.T) {
func TestBooleanAsSchema(t *testing.T) {
t.Parallel()

cfg := basicConfig
testExampleFile(t, cfg, "./data/misc/specialCharacters/specialCharacters.json")
testExampleFile(t, cfg, "./data/misc/booleanAsSchema/booleanAsSchema.json")
}

func TestCapitalization(t *testing.T) {
Expand All @@ -100,11 +100,28 @@ func TestCapitalization(t *testing.T) {
testExampleFile(t, cfg, "./data/misc/capitalization/capitalization.json")
}

func TestBooleanAsSchema(t *testing.T) {
func TestOnlyModels(t *testing.T) {
t.Parallel()

cfg := basicConfig
testExampleFile(t, cfg, "./data/misc/booleanAsSchema/booleanAsSchema.json")
cfg.OnlyModels = false

testExampleFile(t, cfg, "./data/misc/onlyModels/onlyModels.json")
}

func TestSpecialCharacters(t *testing.T) {
t.Parallel()

cfg := basicConfig
testExampleFile(t, cfg, "./data/misc/specialCharacters/specialCharacters.json")
}

func TestTags(t *testing.T) {
t.Parallel()

cfg := basicConfig
cfg.Tags = []string{"yaml"}
testExampleFile(t, cfg, "./data/misc/tags/tags.json")
}

func TestStructNameFromTitle(t *testing.T) {
Expand Down Expand Up @@ -138,14 +155,6 @@ func TestExtraImportsYAML(t *testing.T) {
testExampleFile(t, cfg, "./data/extraImports/gopkgYAMLv3/gopkgYAMLv3.json")
}

func TestTags(t *testing.T) {
t.Parallel()

cfg := basicConfig
cfg.Tags = []string{"yaml"}
testExampleFile(t, cfg, "./data/misc/tags/tags.json")
}

func testExamples(t *testing.T, cfg generator.Config, dataDir string) {
t.Helper()

Expand All @@ -172,15 +181,6 @@ func TestRegressions(t *testing.T) {
testExamples(t, basicConfig, "./data/regressions")
}

func TestOnlyModels(t *testing.T) {
t.Parallel()

cfg := basicConfig
cfg.OnlyModels = true

testExamples(t, cfg, "./data/onlyModels")
}

func testExampleFile(t *testing.T, cfg generator.Config, fileName string) {
t.Helper()

Expand Down

0 comments on commit 925fe1f

Please sign in to comment.