From 0bec0b0f4697abc985c2e850574507e99040992d Mon Sep 17 00:00:00 2001 From: Martin Liu Date: Tue, 5 Dec 2017 13:43:22 -0800 Subject: [PATCH] Imports in generated code should follow conventions --- ginkgo/bootstrap_command.go | 8 ++++---- ginkgo/generate_command.go | 12 ++++++------ .../convert_goldmasters/nested_suite_test.go | 4 ++-- .../_fixtures/convert_goldmasters/suite_test.go | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ginkgo/bootstrap_command.go b/ginkgo/bootstrap_command.go index 1e209e4f5..fea4d4d4e 100644 --- a/ginkgo/bootstrap_command.go +++ b/ginkgo/bootstrap_command.go @@ -43,10 +43,10 @@ func BuildBootstrapCommand() *Command { var bootstrapText = `package {{.Package}} import ( + "testing" + {{.GinkgoImport}} {{.GomegaImport}} - - "testing" ) func Test{{.FormattedName}}(t *testing.T) { @@ -58,11 +58,11 @@ func Test{{.FormattedName}}(t *testing.T) { var agoutiBootstrapText = `package {{.Package}} import ( + "testing" + {{.GinkgoImport}} {{.GomegaImport}} "github.com/sclevine/agouti" - - "testing" ) func Test{{.FormattedName}}(t *testing.T) { diff --git a/ginkgo/generate_command.go b/ginkgo/generate_command.go index 3b9405aa0..019fd2337 100644 --- a/ginkgo/generate_command.go +++ b/ginkgo/generate_command.go @@ -34,10 +34,10 @@ func BuildGenerateCommand() *Command { var specText = `package {{.Package}} import ( - {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}} - {{if .IncludeImports}}. "github.com/onsi/ginkgo"{{end}} {{if .IncludeImports}}. "github.com/onsi/gomega"{{end}} + + {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}} ) var _ = Describe("{{.Subject}}", func() { @@ -45,15 +45,15 @@ var _ = Describe("{{.Subject}}", func() { }) ` -var agoutiSpecText = `package {{.Package}}_test +var agoutiSpecText = `package {{.Package}} import ( - {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}} - {{if .IncludeImports}}. "github.com/onsi/ginkgo"{{end}} {{if .IncludeImports}}. "github.com/onsi/gomega"{{end}} - . "github.com/sclevine/agouti/matchers" "github.com/sclevine/agouti" + . "github.com/sclevine/agouti/matchers" + + {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}} ) var _ = Describe("{{.Subject}}", func() { diff --git a/integration/_fixtures/convert_goldmasters/nested_suite_test.go b/integration/_fixtures/convert_goldmasters/nested_suite_test.go index d3d35e817..721d0f2c3 100644 --- a/integration/_fixtures/convert_goldmasters/nested_suite_test.go +++ b/integration/_fixtures/convert_goldmasters/nested_suite_test.go @@ -1,10 +1,10 @@ package nested_test import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestNested(t *testing.T) { diff --git a/integration/_fixtures/convert_goldmasters/suite_test.go b/integration/_fixtures/convert_goldmasters/suite_test.go index fd69d3336..9ea229135 100644 --- a/integration/_fixtures/convert_goldmasters/suite_test.go +++ b/integration/_fixtures/convert_goldmasters/suite_test.go @@ -1,10 +1,10 @@ package tmp_test import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestConvertFixtures(t *testing.T) {