@@ -2,7 +2,6 @@ package cmd_test
2
2
3
3
import (
4
4
"os"
5
- "strings"
6
5
7
6
"github.com/nimblehq/gin-templates/tests"
8
7
@@ -22,191 +21,191 @@ var _ = Describe("Create template", func() {
22
21
Fail ("Failed to get current directory: " + err .Error ())
23
22
}
24
23
25
- directoryContainProjectName := strings . Contains ( dir , "gin-templates/cmd/test-gin-templates" )
24
+ expectedContent := "gin-templates/cmd/test-gin-templates"
26
25
27
- Expect (directoryContainProjectName ).To (BeTrue ( ))
26
+ Expect (dir ).To (ContainSubstring ( expectedContent ))
28
27
})
29
28
})
30
29
31
30
Context ("given .env.example" , func () {
32
31
It ("contains project name at DATABASE_URL" , func () {
33
32
content := tests .ReadFile (".env.example" )
34
33
35
- fileContainProjectName := strings . Contains ( content , "DATABASE_URL=postgres://postgres:postgres@0.0.0.0:5432/test-gin-templates_development?sslmode=disable" )
34
+ expectedContent := "DATABASE_URL=postgres://postgres:postgres@0.0.0.0:5432/test-gin-templates_development?sslmode=disable"
36
35
37
- Expect (fileContainProjectName ).To (BeTrue ( ))
36
+ Expect (content ).To (ContainSubstring ( expectedContent ))
38
37
})
39
38
})
40
39
41
40
Context ("given .env.test" , func () {
42
41
It ("contains project name at DATABASE_URL" , func () {
43
42
content := tests .ReadFile (".env.test" )
44
43
45
- fileContainProjectName := strings . Contains ( content , "DATABASE_URL=postgres://postgres:postgres@0.0.0.0:5433/test-gin-templates_test?sslmode=disable" )
44
+ expectedContent := "DATABASE_URL=postgres://postgres:postgres@0.0.0.0:5433/test-gin-templates_test?sslmode=disable"
46
45
47
- Expect (fileContainProjectName ).To (BeTrue ( ))
46
+ Expect (content ).To (ContainSubstring ( expectedContent ))
48
47
})
49
48
})
50
49
51
50
Context ("given docker-compose.dev.yml" , func () {
52
51
It ("contains project name at container_name" , func () {
53
52
content := tests .ReadFile ("docker-compose.dev.yml" )
54
53
55
- fileContainProjectName := strings . Contains ( content , "container_name: test-gin-templates_db" )
54
+ expectedContent := "container_name: test-gin-templates_db"
56
55
57
- Expect (fileContainProjectName ).To (BeTrue ( ))
56
+ Expect (content ).To (ContainSubstring ( expectedContent ))
58
57
})
59
58
60
59
It ("contains project name at postgres db env" , func () {
61
60
content := tests .ReadFile ("docker-compose.dev.yml" )
62
61
63
- fileContainProjectName := strings . Contains ( content , "- POSTGRES_DB=test-gin-templates_development" )
62
+ expectedContent := "- POSTGRES_DB=test-gin-templates_development"
64
63
65
- Expect (fileContainProjectName ).To (BeTrue ( ))
64
+ Expect (content ).To (ContainSubstring ( expectedContent ))
66
65
})
67
66
})
68
67
69
68
Context ("given docker-compose.test.yml" , func () {
70
69
It ("contains project name at container_name" , func () {
71
70
content := tests .ReadFile ("docker-compose.test.yml" )
72
71
73
- fileContainProjectName := strings . Contains ( content , "container_name: test-gin-templates_db_test" )
72
+ expectedContent := "container_name: test-gin-templates_db_test"
74
73
75
- Expect (fileContainProjectName ).To (BeTrue ( ))
74
+ Expect (content ).To (ContainSubstring ( expectedContent ))
76
75
})
77
76
78
77
It ("contains project name at postgres db env" , func () {
79
78
content := tests .ReadFile ("docker-compose.test.yml" )
80
79
81
- fileContainProjectName := strings . Contains ( content , "- POSTGRES_DB=test-gin-templates_test" )
80
+ expectedContent := "- POSTGRES_DB=test-gin-templates_test"
82
81
83
- Expect (fileContainProjectName ).To (BeTrue ( ))
82
+ Expect (content ).To (ContainSubstring ( expectedContent ))
84
83
})
85
84
})
86
85
87
86
Context ("given go.mod" , func () {
88
87
It ("contains project name at module name" , func () {
89
88
content := tests .ReadFile ("go.mod" )
90
89
91
- fileContainProjectName := strings . Contains ( content , "module github.com/nimblehq/test-gin-templates" )
90
+ expectedContent := "module github.com/nimblehq/test-gin-templates"
92
91
93
- Expect (fileContainProjectName ).To (BeTrue ( ))
92
+ Expect (content ).To (ContainSubstring ( expectedContent ))
94
93
})
95
94
})
96
95
97
96
Context ("given bootstrap/database.go" , func () {
98
97
It ("contains project name at helpers import" , func () {
99
98
content := tests .ReadFile ("bootstrap/database.go" )
100
99
101
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/helpers"` )
100
+ expectedContent := `"github.com/nimblehq/test-gin-templates/helpers"`
102
101
103
- Expect (fileContainProjectName ).To (BeTrue ( ))
102
+ Expect (content ).To (ContainSubstring ( expectedContent ))
104
103
})
105
104
})
106
105
107
106
Context ("given bootstrap/router.go" , func () {
108
107
It ("contains project name at api v1 routers import" , func () {
109
108
content := tests .ReadFile ("bootstrap/router.go" )
110
109
111
- fileContainProjectName := strings . Contains ( content , `apiv1router "github.com/nimblehq/test-gin-templates/lib/api/v1/routers"` )
110
+ expectedContent := `apiv1router "github.com/nimblehq/test-gin-templates/lib/api/v1/routers"`
112
111
113
- Expect (fileContainProjectName ).To (BeTrue ( ))
112
+ Expect (content ).To (ContainSubstring ( expectedContent ))
114
113
})
115
114
})
116
115
117
116
Context ("given cmd/api/main.go" , func () {
118
117
It ("contains project name at bootstrap import" , func () {
119
118
content := tests .ReadFile ("cmd/api/main.go" )
120
119
121
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/bootstrap"` )
120
+ expectedContent := `"github.com/nimblehq/test-gin-templates/bootstrap"`
122
121
123
- Expect (fileContainProjectName ).To (BeTrue ( ))
122
+ Expect (content ).To (ContainSubstring ( expectedContent ))
124
123
})
125
124
})
126
125
127
126
Context ("given config/app.toml" , func () {
128
127
It ("contains project name at app_name" , func () {
129
128
content := tests .ReadFile ("config/app.toml" )
130
129
131
- fileContainProjectName := strings . Contains ( content , `app_name = "test-gin-templates"` )
130
+ expectedContent := `app_name = "test-gin-templates"`
132
131
133
- Expect (fileContainProjectName ).To (BeTrue ( ))
132
+ Expect (content ).To (ContainSubstring ( expectedContent ))
134
133
})
135
134
136
135
It ("contains project name at debug db name" , func () {
137
136
content := tests .ReadFile ("config/app.toml" )
138
137
139
- fileContainProjectName := strings . Contains ( content , `db_name = "test-gin-templates_development"` )
138
+ expectedContent := `db_name = "test-gin-templates_development"`
140
139
141
- Expect (fileContainProjectName ).To (BeTrue ( ))
140
+ Expect (content ).To (ContainSubstring ( expectedContent ))
142
141
})
143
142
144
143
It ("contains project name at test db name" , func () {
145
144
content := tests .ReadFile ("config/app.toml" )
146
145
147
- fileContainProjectName := strings . Contains ( content , `db_name = "test-gin-templates_test"` )
146
+ expectedContent := `db_name = "test-gin-templates_test"`
148
147
149
- Expect (fileContainProjectName ).To (BeTrue ( ))
148
+ Expect (content ).To (ContainSubstring ( expectedContent ))
150
149
})
151
150
})
152
151
153
152
Context ("given helpers/config_test.go" , func () {
154
153
It ("contains project name at helpers import" , func () {
155
154
content := tests .ReadFile ("helpers/config_test.go" )
156
155
157
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/helpers"` )
156
+ expectedContent := `"github.com/nimblehq/test-gin-templates/helpers"`
158
157
159
- Expect (fileContainProjectName ).To (BeTrue ( ))
158
+ Expect (content ).To (ContainSubstring ( expectedContent ))
160
159
})
161
160
})
162
161
163
162
Context ("given helpers/helpers_suite_test.go" , func () {
164
163
It ("contains project name at test import" , func () {
165
164
content := tests .ReadFile ("helpers/helpers_suite_test.go" )
166
165
167
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/test"` )
166
+ expectedContent := `"github.com/nimblehq/test-gin-templates/test"`
168
167
169
- Expect (fileContainProjectName ).To (BeTrue ( ))
168
+ Expect (content ).To (ContainSubstring ( expectedContent ))
170
169
})
171
170
})
172
171
173
172
Context ("given lib/api/v1/controllers/controllers_suite_test.go" , func () {
174
173
It ("contains project name at test import" , func () {
175
174
content := tests .ReadFile ("lib/api/v1/controllers/controllers_suite_test.go" )
176
175
177
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/test"` )
176
+ expectedContent := `"github.com/nimblehq/test-gin-templates/test"`
178
177
179
- Expect (fileContainProjectName ).To (BeTrue ( ))
178
+ Expect (content ).To (ContainSubstring ( expectedContent ))
180
179
})
181
180
})
182
181
183
182
Context ("given lib/api/v1/controllers/health_test.go" , func () {
184
183
It ("contains project name at test import" , func () {
185
184
content := tests .ReadFile ("lib/api/v1/controllers/health_test.go" )
186
185
187
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/test"` )
186
+ expectedContent := `"github.com/nimblehq/test-gin-templates/test"`
188
187
189
- Expect (fileContainProjectName ).To (BeTrue ( ))
188
+ Expect (content ).To (ContainSubstring ( expectedContent ))
190
189
})
191
190
})
192
191
193
192
Context ("given lib/api/v1/routers/router.go" , func () {
194
193
It ("contains project name at api v1 controllers import" , func () {
195
194
content := tests .ReadFile ("lib/api/v1/routers/router.go" )
196
195
197
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/lib/api/v1/controllers"` )
196
+ expectedContent := `"github.com/nimblehq/test-gin-templates/lib/api/v1/controllers"`
198
197
199
- Expect (fileContainProjectName ).To (BeTrue ( ))
198
+ Expect (content ).To (ContainSubstring ( expectedContent ))
200
199
})
201
200
})
202
201
203
202
Context ("given test/test.go" , func () {
204
203
It ("contains project name at bootstrap import" , func () {
205
204
content := tests .ReadFile ("test/test.go" )
206
205
207
- fileContainProjectName := strings . Contains ( content , `"github.com/nimblehq/test-gin-templates/bootstrap"` )
206
+ expectedContent := `"github.com/nimblehq/test-gin-templates/bootstrap"`
208
207
209
- Expect (fileContainProjectName ).To (BeTrue ( ))
208
+ Expect (content ).To (ContainSubstring ( expectedContent ))
210
209
})
211
210
})
212
211
})
0 commit comments