Skip to content

Commit 5dcde3f

Browse files
authored
[Go][Server] better tests (#4295)
* better test for go-api-server * better test for go gin server * fix go-api-server test * fix folder path * remove red test * update test files * update script with gofmt * update windows batch files * discard changes before running ensure-up-to-date * add go-api-server to ensure uptodate script
1 parent 28a87b0 commit 5dcde3f

9 files changed

Lines changed: 136 additions & 8 deletions

File tree

CI/circle_parallel.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ elif [ "$NODE_INDEX" = "2" ]; then
2424
# install elm-format
2525
npm install -g elm-format
2626

27+
# clear any changes to the samples
28+
git checkout -- .
29+
30+
# look for outdated samples
2731
./bin/utils/ensure-up-to-date
2832
fi
2933
#elif [ "$NODE_INDEX" = "3" ]; then

bin/go-gin-petstore-server.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ SPEC="modules/openapi-generator/src/test/resources/2_0/petstore.yaml"
2929
GENERATOR="go-gin-server"
3030
STUB_DIR="samples/server/petstore/go-gin-api-server"
3131

32-
echo "Removing files and folders under $STUB_DIR"
33-
rm -rf $STUB_DIR
32+
echo "Removing auto-generated files and folders under $STUB_DIR"
33+
rm -rf $STUB_DIR/go
3434

3535
# if you've executed sbt assembly previously it will use that instead.
3636
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3737

3838
ags="generate -t modules/openapi-generator/src/main/resources/go-gin-server -i $SPEC -g $GENERATOR -o $STUB_DIR --additional-properties packageName=petstoreserver --additional-properties hideGenerationTimestamp=true $@"
3939

4040
java $JAVA_OPTS -jar $executable $ags
41-
#!/usr/bin/env bash

bin/go-petstore-server.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ SPEC="modules/openapi-generator/src/test/resources/2_0/petstore.yaml"
2929
GENERATOR="go-server"
3030
STUB_DIR="samples/server/petstore/go-api-server"
3131

32-
echo "Removing files and folders under $STUB_DIR"
33-
rm -rf $STUB_DIR
32+
echo "Removing auto-generated files and folders under $STUB_DIR"
33+
rm -rf $STUB_DIR/go
3434

3535
# if you've executed sbt assembly previously it will use that instead.
3636
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"

bin/utils/ensure-up-to-date

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ declare -a scripts=(
6161
"./bin/go-experimental-petstore.sh"
6262
"./bin/go-petstore.sh"
6363
"./bin/go-petstore-withxml.sh"
64+
"./bin/go-petstore-server.sh"
6465
"./bin/go-gin-petstore-server.sh"
6566
"./bin/groovy-petstore.sh"
6667
"./bin/apex-petstore.sh"

bin/windows/go-gin-petstore-server.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set GENERATOR=go-gin-server
1111
set STUB_DIR=samples\server\petstore\go-gin-api-server
1212

1313
echo Removing files and folders under %STUB_DIR%
14-
del /F /S /Q %STUB_DIR%
14+
del /F /S /Q %STUB_DIR%\go
1515

1616
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
1717
set ags=generate -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstoreserver

bin/windows/go-petstore-server.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ set GENERATOR=go-server
1111
set STUB_DIR=samples\server\petstore\go-api-server
1212

1313
echo Removing files and folders under %STUB_DIR%
14-
del /F /S /Q %STUB_DIR%
14+
del /F /S /Q %STUB_DIR%\go
1515

1616
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
1717
set ags=generate -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstoreserver
1818

1919
java %JAVA_OPTS% -jar %executable% %ags%
2020

21-
endlocal
21+
endlocal

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,8 @@
11831183
</property>
11841184
</activation>
11851185
<modules>
1186+
<module>samples/server/petstore/go-api-server</module>
1187+
<module>samples/server/petstore/go-gin-api-server</module>
11861188
<!-- clients -->
11871189
<module>samples/openapi3/client/petstore/ruby</module>
11881190
<!-- test java-related projects -->
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>GoApiServer</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Go Api Server</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.codehaus.mojo</groupId>
26+
<artifactId>exec-maven-plugin</artifactId>
27+
<version>1.2.1</version>
28+
<executions>
29+
<execution>
30+
<id>gofmt-test</id>
31+
<phase>integration-test</phase>
32+
<goals>
33+
<goal>exec</goal>
34+
</goals>
35+
<configuration>
36+
<executable>gofmt</executable>
37+
<arguments>
38+
<argument>-w</argument>
39+
<argument>./main.go</argument>
40+
</arguments>
41+
</configuration>
42+
</execution>
43+
<execution>
44+
<id>gofmt-file-test</id>
45+
<phase>integration-test</phase>
46+
<goals>
47+
<goal>exec</goal>
48+
</goals>
49+
<configuration>
50+
<executable>gofmt</executable>
51+
<arguments>
52+
<argument>-w</argument>
53+
<argument>./go/</argument>
54+
</arguments>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
</project>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>GoGinServer</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Go Gin Server</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.codehaus.mojo</groupId>
26+
<artifactId>exec-maven-plugin</artifactId>
27+
<version>1.2.1</version>
28+
<executions>
29+
<execution>
30+
<id>gofmt-test</id>
31+
<phase>integration-test</phase>
32+
<goals>
33+
<goal>exec</goal>
34+
</goals>
35+
<configuration>
36+
<executable>gofmt</executable>
37+
<arguments>
38+
<argument>-w</argument>
39+
<argument>./main.go</argument>
40+
</arguments>
41+
</configuration>
42+
</execution>
43+
<execution>
44+
<id>gofmt-file-test</id>
45+
<phase>integration-test</phase>
46+
<goals>
47+
<goal>exec</goal>
48+
</goals>
49+
<configuration>
50+
<executable>gofmt</executable>
51+
<arguments>
52+
<argument>-w</argument>
53+
<argument>./go/</argument>
54+
</arguments>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
</project>

0 commit comments

Comments
 (0)