generated from nimblehq/git-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from nimblehq/chore/refactor-create-template-test
Update assertion to use ContainSubstring matcher
- Loading branch information
Showing
1 changed file
with
40 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package cmd_test | |
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/nimblehq/gin-templates/tests" | ||
|
||
|
@@ -22,191 +21,191 @@ var _ = Describe("Create template", func() { | |
Fail("Failed to get current directory: " + err.Error()) | ||
} | ||
|
||
directoryContainProjectName := strings.Contains(dir, "gin-templates/cmd/test-gin-templates") | ||
expectedContent := "gin-templates/cmd/test-gin-templates" | ||
|
||
Expect(directoryContainProjectName).To(BeTrue()) | ||
Expect(dir).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given .env.example", func() { | ||
It("contains project name at DATABASE_URL", func() { | ||
content := tests.ReadFile(".env.example") | ||
|
||
fileContainProjectName := strings.Contains(content, "DATABASE_URL=postgres://postgres:[email protected]:5432/test-gin-templates_development?sslmode=disable") | ||
expectedContent := "DATABASE_URL=postgres://postgres:[email protected]:5432/test-gin-templates_development?sslmode=disable" | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given .env.test", func() { | ||
It("contains project name at DATABASE_URL", func() { | ||
content := tests.ReadFile(".env.test") | ||
|
||
fileContainProjectName := strings.Contains(content, "DATABASE_URL=postgres://postgres:[email protected]:5433/test-gin-templates_test?sslmode=disable") | ||
expectedContent := "DATABASE_URL=postgres://postgres:[email protected]:5433/test-gin-templates_test?sslmode=disable" | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given docker-compose.dev.yml", func() { | ||
It("contains project name at container_name", func() { | ||
content := tests.ReadFile("docker-compose.dev.yml") | ||
|
||
fileContainProjectName := strings.Contains(content, "container_name: test-gin-templates_db") | ||
expectedContent := "container_name: test-gin-templates_db" | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
|
||
It("contains project name at postgres db env", func() { | ||
content := tests.ReadFile("docker-compose.dev.yml") | ||
|
||
fileContainProjectName := strings.Contains(content, "- POSTGRES_DB=test-gin-templates_development") | ||
expectedContent := "- POSTGRES_DB=test-gin-templates_development" | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given docker-compose.test.yml", func() { | ||
It("contains project name at container_name", func() { | ||
content := tests.ReadFile("docker-compose.test.yml") | ||
|
||
fileContainProjectName := strings.Contains(content, "container_name: test-gin-templates_db_test") | ||
expectedContent := "container_name: test-gin-templates_db_test" | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
|
||
It("contains project name at postgres db env", func() { | ||
content := tests.ReadFile("docker-compose.test.yml") | ||
|
||
fileContainProjectName := strings.Contains(content, "- POSTGRES_DB=test-gin-templates_test") | ||
expectedContent := "- POSTGRES_DB=test-gin-templates_test" | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given go.mod", func() { | ||
It("contains project name at module name", func() { | ||
content := tests.ReadFile("go.mod") | ||
|
||
fileContainProjectName := strings.Contains(content, "module github.com/nimblehq/test-gin-templates") | ||
expectedContent := "module github.com/nimblehq/test-gin-templates" | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given bootstrap/database.go", func() { | ||
It("contains project name at helpers import", func() { | ||
content := tests.ReadFile("bootstrap/database.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/helpers"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/helpers"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given bootstrap/router.go", func() { | ||
It("contains project name at api v1 routers import", func() { | ||
content := tests.ReadFile("bootstrap/router.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `apiv1router "github.com/nimblehq/test-gin-templates/lib/api/v1/routers"`) | ||
expectedContent := `apiv1router "github.com/nimblehq/test-gin-templates/lib/api/v1/routers"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given cmd/api/main.go", func() { | ||
It("contains project name at bootstrap import", func() { | ||
content := tests.ReadFile("cmd/api/main.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/bootstrap"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/bootstrap"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given config/app.toml", func() { | ||
It("contains project name at app_name", func() { | ||
content := tests.ReadFile("config/app.toml") | ||
|
||
fileContainProjectName := strings.Contains(content, `app_name = "test-gin-templates"`) | ||
expectedContent := `app_name = "test-gin-templates"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
|
||
It("contains project name at debug db name", func() { | ||
content := tests.ReadFile("config/app.toml") | ||
|
||
fileContainProjectName := strings.Contains(content, `db_name = "test-gin-templates_development"`) | ||
expectedContent := `db_name = "test-gin-templates_development"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
|
||
It("contains project name at test db name", func() { | ||
content := tests.ReadFile("config/app.toml") | ||
|
||
fileContainProjectName := strings.Contains(content, `db_name = "test-gin-templates_test"`) | ||
expectedContent := `db_name = "test-gin-templates_test"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given helpers/config_test.go", func() { | ||
It("contains project name at helpers import", func() { | ||
content := tests.ReadFile("helpers/config_test.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/helpers"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/helpers"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given helpers/helpers_suite_test.go", func() { | ||
It("contains project name at test import", func() { | ||
content := tests.ReadFile("helpers/helpers_suite_test.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/test"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/test"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given lib/api/v1/controllers/controllers_suite_test.go", func() { | ||
It("contains project name at test import", func() { | ||
content := tests.ReadFile("lib/api/v1/controllers/controllers_suite_test.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/test"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/test"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given lib/api/v1/controllers/health_test.go", func() { | ||
It("contains project name at test import", func() { | ||
content := tests.ReadFile("lib/api/v1/controllers/health_test.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/test"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/test"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given lib/api/v1/routers/router.go", func() { | ||
It("contains project name at api v1 controllers import", func() { | ||
content := tests.ReadFile("lib/api/v1/routers/router.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/lib/api/v1/controllers"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/lib/api/v1/controllers"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
|
||
Context("given test/test.go", func() { | ||
It("contains project name at bootstrap import", func() { | ||
content := tests.ReadFile("test/test.go") | ||
|
||
fileContainProjectName := strings.Contains(content, `"github.com/nimblehq/test-gin-templates/bootstrap"`) | ||
expectedContent := `"github.com/nimblehq/test-gin-templates/bootstrap"` | ||
|
||
Expect(fileContainProjectName).To(BeTrue()) | ||
Expect(content).To(ContainSubstring(expectedContent)) | ||
}) | ||
}) | ||
}) |