Skip to content

Commit

Permalink
Merge pull request #113 from nimblehq/release/2.2.0
Browse files Browse the repository at this point in the history
Release 2.2.0
  • Loading branch information
carryall authored Aug 30, 2023
2 parents 9b13cd4 + ad4b942 commit 77a8442
Show file tree
Hide file tree
Showing 39 changed files with 702 additions and 96 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ Check this [wiki](https://github.com/nimblehq/gin-templates/wiki/Directories) fo
make test
```

## Development

- Build the command with

```sh
go build -o <PATH_TO_STORE_BUILD_FILE>
```

- Run the build file follow by the `create` command and the prompt to create a Go project should appear

```sh
<PATH_TO_STORE_BUILD_FILE> create
```

## License

This project is Copyright (c) 2014 and onwards Nimble. It is free software,
Expand Down
322 changes: 261 additions & 61 deletions cmd/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,19 +663,6 @@ var _ = Describe("Create template", func() {

Expect(content).To(ContainSubstring(expectedContent))
})

It("contains Node 14 in README.md", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.Web,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("README.md")

expectedContent := "[Node - 14](https://nodejs.org/en/)"

Expect(content).To(ContainSubstring(expectedContent))
})
})

Context("given NO Web variant", func() {
Expand All @@ -690,17 +677,6 @@ var _ = Describe("Create template", func() {
Expect(os.IsNotExist(err)).To(BeTrue())
})

It("does NOT contain .eslintrc.json file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.API,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat(".eslintrc.json")

Expect(os.IsNotExist(err)).To(BeTrue())
})

It("does NOT contain .npmrc file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Expand All @@ -712,17 +688,6 @@ var _ = Describe("Create template", func() {
Expect(os.IsNotExist(err)).To(BeTrue())
})

It("does NOT contain package.json file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.API,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat("package.json")

Expect(os.IsNotExist(err)).To(BeTrue())
})

It("does NOT contain snowpack.config.js file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Expand Down Expand Up @@ -781,32 +746,6 @@ var _ = Describe("Create template", func() {

Expect(content).NotTo(ContainSubstring(expectedContent))
})

It("does NOT contain npm install in Makefile", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.API,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("Makefile")

expectedContent := "npm install"

Expect(content).NotTo(ContainSubstring(expectedContent))
})

It("does NOT contain Node 14 in README.md", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.API,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("README.md")

expectedContent := "[Node - 14](https://nodejs.org/en/)"

Expect(content).NotTo(ContainSubstring(expectedContent))
})
})

Context("given bootstrap add-on", func() {
Expand Down Expand Up @@ -1012,4 +951,265 @@ var _ = Describe("Create template", func() {
Expect(content).NotTo(ContainSubstring(expectedContent))
})
})

Context("given openapi add-on", func() {
Context("given only Web variant", func() {
It("does NOT contains openapi requirement in .eslintrc.json", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.Web,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile(".eslintrc.json")

expectedContent := `plugin:yml/recommended`

Expect(content).NotTo(ContainSubstring(expectedContent))
})
})

Context("given only API variant", func() {
It("contains openapi requirement in .eslintrc.json", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.API,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile(".eslintrc.json")

expectedContent := `plugin:yml/recommended`

Expect(content).To(ContainSubstring(expectedContent))
})
})

Context("given both variant", func() {
It("contains openapi requirement in .eslintrc.json", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
Variant: tests.Both,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile(".eslintrc.json")

expectedContent := `plugin:yml/recommended`

Expect(content).To(ContainSubstring(expectedContent))
})
})

It("contains docs/openapi folder", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat("docs/openapi")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains openapi instruction in README", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("README.md")

expectedContent := "Generate API documentation"

Expect(content).To(ContainSubstring(expectedContent))
})

It("contains .dockerignore file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat(".dockerignore")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains .eslintignore file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat(".eslintignore")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains .github/workflows/lint_docs.yml file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat(".github/workflows/lint_docs.yml")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains openapi requirement in .gitignore", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile(".gitignore")

expectedContent := "/public/openapi.yml"

Expect(content).To(ContainSubstring(expectedContent))
})

It("contains .spectral.yaml file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat(".spectral.yaml")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains openapi requirement in .tool-versions", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile(".tool-versions")

expectedContent := "nodejs 18.15.0"

Expect(content).To(ContainSubstring(expectedContent))
})

It("contains openapi requirement in Makefile", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("Makefile")

expectedContent := "npm run build:docs"

Expect(content).To(ContainSubstring(expectedContent))
})

It("contains openapi requirement in package.json", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("package.json")

expectedContent := `"build:docs": "swagger-cli bundle docs/openapi/openapi.yml --outfile public/openapi.yml --type yaml"`

Expect(content).To(ContainSubstring(expectedContent))
})

It("contains lib/api/docs folder", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat("lib/api/docs")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains openapi requirement in go.mod", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("go.mod")

expectedContent := "github.com/gin-gonic/contrib"

Expect(content).To(ContainSubstring(expectedContent))
})

It("contains openapi requirement in router.go", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
content := tests.ReadFile("bootstrap/router.go")

expectedContent := "apidocsrouter.CombineRoutes(r)"

Expect(content).To(ContainSubstring(expectedContent))
})
})

Context("given mock_server add-on", func() {
It("contains deploy_mock_server.yml file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
UseMockServer: tests.Yes,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat(".github/workflows/deploy_mock_server.yml")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains Dockerfile.mock file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
UseMockServer: tests.Yes,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat("Dockerfile.mock")

Expect(os.IsNotExist(err)).To(BeFalse())
})

It("contains fly.toml file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
UseMockServer: tests.Yes,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat("fly.toml")

Expect(os.IsNotExist(err)).To(BeFalse())
})
})

Context("given NO mock_server add-on", func() {
It("does NOT contains deploy_mock_server.yml file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
UseMockServer: tests.No,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat(".github/workflows/deploy_mock_server.yml")

Expect(os.IsNotExist(err)).To(BeTrue())
})

It("does NOT contains Dockerfile.mock file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
UseMockServer: tests.No,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat("Dockerfile.mock")

Expect(os.IsNotExist(err)).To(BeTrue())
})

It("does NOT contains fly.toml file", func() {
cookiecutter := tests.Cookiecutter{
AppName: "test-gin-templates",
UseMockServer: tests.No,
}
cookiecutter.CreateProjectFromGinTemplate(currentTemplatePath)
_, err := os.Stat("fly.toml")

Expect(os.IsNotExist(err)).To(BeTrue())
})
})
})
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"css_addon": ["Bootstrap", "Tailwind", "None"],
"use_logrus": ["yes", "no"],
"use_heroku": ["yes", "no"],
"use_mock_server": ["yes", "no"],

"_api_variant": "no",
"_web_variant": "no",
Expand Down
Loading

0 comments on commit 77a8442

Please sign in to comment.