@@ -663,19 +663,6 @@ var _ = Describe("Create template", func() {
663
663
664
664
Expect (content ).To (ContainSubstring (expectedContent ))
665
665
})
666
-
667
- It ("contains Node 14 in README.md" , func () {
668
- cookiecutter := tests.Cookiecutter {
669
- AppName : "test-gin-templates" ,
670
- Variant : tests .Web ,
671
- }
672
- cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
673
- content := tests .ReadFile ("README.md" )
674
-
675
- expectedContent := "[Node - 14](https://nodejs.org/en/)"
676
-
677
- Expect (content ).To (ContainSubstring (expectedContent ))
678
- })
679
666
})
680
667
681
668
Context ("given NO Web variant" , func () {
@@ -690,17 +677,6 @@ var _ = Describe("Create template", func() {
690
677
Expect (os .IsNotExist (err )).To (BeTrue ())
691
678
})
692
679
693
- It ("does NOT contain .eslintrc.json file" , func () {
694
- cookiecutter := tests.Cookiecutter {
695
- AppName : "test-gin-templates" ,
696
- Variant : tests .API ,
697
- }
698
- cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
699
- _ , err := os .Stat (".eslintrc.json" )
700
-
701
- Expect (os .IsNotExist (err )).To (BeTrue ())
702
- })
703
-
704
680
It ("does NOT contain .npmrc file" , func () {
705
681
cookiecutter := tests.Cookiecutter {
706
682
AppName : "test-gin-templates" ,
@@ -712,17 +688,6 @@ var _ = Describe("Create template", func() {
712
688
Expect (os .IsNotExist (err )).To (BeTrue ())
713
689
})
714
690
715
- It ("does NOT contain package.json file" , func () {
716
- cookiecutter := tests.Cookiecutter {
717
- AppName : "test-gin-templates" ,
718
- Variant : tests .API ,
719
- }
720
- cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
721
- _ , err := os .Stat ("package.json" )
722
-
723
- Expect (os .IsNotExist (err )).To (BeTrue ())
724
- })
725
-
726
691
It ("does NOT contain snowpack.config.js file" , func () {
727
692
cookiecutter := tests.Cookiecutter {
728
693
AppName : "test-gin-templates" ,
@@ -781,32 +746,6 @@ var _ = Describe("Create template", func() {
781
746
782
747
Expect (content ).NotTo (ContainSubstring (expectedContent ))
783
748
})
784
-
785
- It ("does NOT contain npm install in Makefile" , func () {
786
- cookiecutter := tests.Cookiecutter {
787
- AppName : "test-gin-templates" ,
788
- Variant : tests .API ,
789
- }
790
- cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
791
- content := tests .ReadFile ("Makefile" )
792
-
793
- expectedContent := "npm install"
794
-
795
- Expect (content ).NotTo (ContainSubstring (expectedContent ))
796
- })
797
-
798
- It ("does NOT contain Node 14 in README.md" , func () {
799
- cookiecutter := tests.Cookiecutter {
800
- AppName : "test-gin-templates" ,
801
- Variant : tests .API ,
802
- }
803
- cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
804
- content := tests .ReadFile ("README.md" )
805
-
806
- expectedContent := "[Node - 14](https://nodejs.org/en/)"
807
-
808
- Expect (content ).NotTo (ContainSubstring (expectedContent ))
809
- })
810
749
})
811
750
812
751
Context ("given bootstrap add-on" , func () {
@@ -1012,4 +951,265 @@ var _ = Describe("Create template", func() {
1012
951
Expect (content ).NotTo (ContainSubstring (expectedContent ))
1013
952
})
1014
953
})
954
+
955
+ Context ("given openapi add-on" , func () {
956
+ Context ("given only Web variant" , func () {
957
+ It ("does NOT contains openapi requirement in .eslintrc.json" , func () {
958
+ cookiecutter := tests.Cookiecutter {
959
+ AppName : "test-gin-templates" ,
960
+ Variant : tests .Web ,
961
+ }
962
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
963
+ content := tests .ReadFile (".eslintrc.json" )
964
+
965
+ expectedContent := `plugin:yml/recommended`
966
+
967
+ Expect (content ).NotTo (ContainSubstring (expectedContent ))
968
+ })
969
+ })
970
+
971
+ Context ("given only API variant" , func () {
972
+ It ("contains openapi requirement in .eslintrc.json" , func () {
973
+ cookiecutter := tests.Cookiecutter {
974
+ AppName : "test-gin-templates" ,
975
+ Variant : tests .API ,
976
+ }
977
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
978
+ content := tests .ReadFile (".eslintrc.json" )
979
+
980
+ expectedContent := `plugin:yml/recommended`
981
+
982
+ Expect (content ).To (ContainSubstring (expectedContent ))
983
+ })
984
+ })
985
+
986
+ Context ("given both variant" , func () {
987
+ It ("contains openapi requirement in .eslintrc.json" , func () {
988
+ cookiecutter := tests.Cookiecutter {
989
+ AppName : "test-gin-templates" ,
990
+ Variant : tests .Both ,
991
+ }
992
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
993
+ content := tests .ReadFile (".eslintrc.json" )
994
+
995
+ expectedContent := `plugin:yml/recommended`
996
+
997
+ Expect (content ).To (ContainSubstring (expectedContent ))
998
+ })
999
+ })
1000
+
1001
+ It ("contains docs/openapi folder" , func () {
1002
+ cookiecutter := tests.Cookiecutter {
1003
+ AppName : "test-gin-templates" ,
1004
+ }
1005
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1006
+ _ , err := os .Stat ("docs/openapi" )
1007
+
1008
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1009
+ })
1010
+
1011
+ It ("contains openapi instruction in README" , func () {
1012
+ cookiecutter := tests.Cookiecutter {
1013
+ AppName : "test-gin-templates" ,
1014
+ }
1015
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1016
+ content := tests .ReadFile ("README.md" )
1017
+
1018
+ expectedContent := "Generate API documentation"
1019
+
1020
+ Expect (content ).To (ContainSubstring (expectedContent ))
1021
+ })
1022
+
1023
+ It ("contains .dockerignore file" , func () {
1024
+ cookiecutter := tests.Cookiecutter {
1025
+ AppName : "test-gin-templates" ,
1026
+ }
1027
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1028
+ _ , err := os .Stat (".dockerignore" )
1029
+
1030
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1031
+ })
1032
+
1033
+ It ("contains .eslintignore file" , func () {
1034
+ cookiecutter := tests.Cookiecutter {
1035
+ AppName : "test-gin-templates" ,
1036
+ }
1037
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1038
+ _ , err := os .Stat (".eslintignore" )
1039
+
1040
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1041
+ })
1042
+
1043
+ It ("contains .github/workflows/lint_docs.yml file" , func () {
1044
+ cookiecutter := tests.Cookiecutter {
1045
+ AppName : "test-gin-templates" ,
1046
+ }
1047
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1048
+ _ , err := os .Stat (".github/workflows/lint_docs.yml" )
1049
+
1050
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1051
+ })
1052
+
1053
+ It ("contains openapi requirement in .gitignore" , func () {
1054
+ cookiecutter := tests.Cookiecutter {
1055
+ AppName : "test-gin-templates" ,
1056
+ }
1057
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1058
+ content := tests .ReadFile (".gitignore" )
1059
+
1060
+ expectedContent := "/public/openapi.yml"
1061
+
1062
+ Expect (content ).To (ContainSubstring (expectedContent ))
1063
+ })
1064
+
1065
+ It ("contains .spectral.yaml file" , func () {
1066
+ cookiecutter := tests.Cookiecutter {
1067
+ AppName : "test-gin-templates" ,
1068
+ }
1069
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1070
+ _ , err := os .Stat (".spectral.yaml" )
1071
+
1072
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1073
+ })
1074
+
1075
+ It ("contains openapi requirement in .tool-versions" , func () {
1076
+ cookiecutter := tests.Cookiecutter {
1077
+ AppName : "test-gin-templates" ,
1078
+ }
1079
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1080
+ content := tests .ReadFile (".tool-versions" )
1081
+
1082
+ expectedContent := "nodejs 18.15.0"
1083
+
1084
+ Expect (content ).To (ContainSubstring (expectedContent ))
1085
+ })
1086
+
1087
+ It ("contains openapi requirement in Makefile" , func () {
1088
+ cookiecutter := tests.Cookiecutter {
1089
+ AppName : "test-gin-templates" ,
1090
+ }
1091
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1092
+ content := tests .ReadFile ("Makefile" )
1093
+
1094
+ expectedContent := "npm run build:docs"
1095
+
1096
+ Expect (content ).To (ContainSubstring (expectedContent ))
1097
+ })
1098
+
1099
+ It ("contains openapi requirement in package.json" , func () {
1100
+ cookiecutter := tests.Cookiecutter {
1101
+ AppName : "test-gin-templates" ,
1102
+ }
1103
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1104
+ content := tests .ReadFile ("package.json" )
1105
+
1106
+ expectedContent := `"build:docs": "swagger-cli bundle docs/openapi/openapi.yml --outfile public/openapi.yml --type yaml"`
1107
+
1108
+ Expect (content ).To (ContainSubstring (expectedContent ))
1109
+ })
1110
+
1111
+ It ("contains lib/api/docs folder" , func () {
1112
+ cookiecutter := tests.Cookiecutter {
1113
+ AppName : "test-gin-templates" ,
1114
+ }
1115
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1116
+ _ , err := os .Stat ("lib/api/docs" )
1117
+
1118
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1119
+ })
1120
+
1121
+ It ("contains openapi requirement in go.mod" , func () {
1122
+ cookiecutter := tests.Cookiecutter {
1123
+ AppName : "test-gin-templates" ,
1124
+ }
1125
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1126
+ content := tests .ReadFile ("go.mod" )
1127
+
1128
+ expectedContent := "github.com/gin-gonic/contrib"
1129
+
1130
+ Expect (content ).To (ContainSubstring (expectedContent ))
1131
+ })
1132
+
1133
+ It ("contains openapi requirement in router.go" , func () {
1134
+ cookiecutter := tests.Cookiecutter {
1135
+ AppName : "test-gin-templates" ,
1136
+ }
1137
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1138
+ content := tests .ReadFile ("bootstrap/router.go" )
1139
+
1140
+ expectedContent := "apidocsrouter.CombineRoutes(r)"
1141
+
1142
+ Expect (content ).To (ContainSubstring (expectedContent ))
1143
+ })
1144
+ })
1145
+
1146
+ Context ("given mock_server add-on" , func () {
1147
+ It ("contains deploy_mock_server.yml file" , func () {
1148
+ cookiecutter := tests.Cookiecutter {
1149
+ AppName : "test-gin-templates" ,
1150
+ UseMockServer : tests .Yes ,
1151
+ }
1152
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1153
+ _ , err := os .Stat (".github/workflows/deploy_mock_server.yml" )
1154
+
1155
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1156
+ })
1157
+
1158
+ It ("contains Dockerfile.mock file" , func () {
1159
+ cookiecutter := tests.Cookiecutter {
1160
+ AppName : "test-gin-templates" ,
1161
+ UseMockServer : tests .Yes ,
1162
+ }
1163
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1164
+ _ , err := os .Stat ("Dockerfile.mock" )
1165
+
1166
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1167
+ })
1168
+
1169
+ It ("contains fly.toml file" , func () {
1170
+ cookiecutter := tests.Cookiecutter {
1171
+ AppName : "test-gin-templates" ,
1172
+ UseMockServer : tests .Yes ,
1173
+ }
1174
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1175
+ _ , err := os .Stat ("fly.toml" )
1176
+
1177
+ Expect (os .IsNotExist (err )).To (BeFalse ())
1178
+ })
1179
+ })
1180
+
1181
+ Context ("given NO mock_server add-on" , func () {
1182
+ It ("does NOT contains deploy_mock_server.yml file" , func () {
1183
+ cookiecutter := tests.Cookiecutter {
1184
+ AppName : "test-gin-templates" ,
1185
+ UseMockServer : tests .No ,
1186
+ }
1187
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1188
+ _ , err := os .Stat (".github/workflows/deploy_mock_server.yml" )
1189
+
1190
+ Expect (os .IsNotExist (err )).To (BeTrue ())
1191
+ })
1192
+
1193
+ It ("does NOT contains Dockerfile.mock file" , func () {
1194
+ cookiecutter := tests.Cookiecutter {
1195
+ AppName : "test-gin-templates" ,
1196
+ UseMockServer : tests .No ,
1197
+ }
1198
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1199
+ _ , err := os .Stat ("Dockerfile.mock" )
1200
+
1201
+ Expect (os .IsNotExist (err )).To (BeTrue ())
1202
+ })
1203
+
1204
+ It ("does NOT contains fly.toml file" , func () {
1205
+ cookiecutter := tests.Cookiecutter {
1206
+ AppName : "test-gin-templates" ,
1207
+ UseMockServer : tests .No ,
1208
+ }
1209
+ cookiecutter .CreateProjectFromGinTemplate (currentTemplatePath )
1210
+ _ , err := os .Stat ("fly.toml" )
1211
+
1212
+ Expect (os .IsNotExist (err )).To (BeTrue ())
1213
+ })
1214
+ })
1015
1215
})
0 commit comments