Skip to content

Commit

Permalink
[Go][Server] better tests (#4295)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wing328 authored Oct 29, 2019
1 parent 28a87b0 commit 5dcde3f
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CI/circle_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ elif [ "$NODE_INDEX" = "2" ]; then
# install elm-format
npm install -g elm-format

# clear any changes to the samples
git checkout -- .

# look for outdated samples
./bin/utils/ensure-up-to-date
fi
#elif [ "$NODE_INDEX" = "3" ]; then
Expand Down
5 changes: 2 additions & 3 deletions bin/go-gin-petstore-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ SPEC="modules/openapi-generator/src/test/resources/2_0/petstore.yaml"
GENERATOR="go-gin-server"
STUB_DIR="samples/server/petstore/go-gin-api-server"

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

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

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 $@"

java $JAVA_OPTS -jar $executable $ags
#!/usr/bin/env bash
4 changes: 2 additions & 2 deletions bin/go-petstore-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ SPEC="modules/openapi-generator/src/test/resources/2_0/petstore.yaml"
GENERATOR="go-server"
STUB_DIR="samples/server/petstore/go-api-server"

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

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
Expand Down
1 change: 1 addition & 0 deletions bin/utils/ensure-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ declare -a scripts=(
"./bin/go-experimental-petstore.sh"
"./bin/go-petstore.sh"
"./bin/go-petstore-withxml.sh"
"./bin/go-petstore-server.sh"
"./bin/go-gin-petstore-server.sh"
"./bin/groovy-petstore.sh"
"./bin/apex-petstore.sh"
Expand Down
2 changes: 1 addition & 1 deletion bin/windows/go-gin-petstore-server.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set GENERATOR=go-gin-server
set STUB_DIR=samples\server\petstore\go-gin-api-server

echo Removing files and folders under %STUB_DIR%
del /F /S /Q %STUB_DIR%
del /F /S /Q %STUB_DIR%\go

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstoreserver
Expand Down
4 changes: 2 additions & 2 deletions bin/windows/go-petstore-server.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ set GENERATOR=go-server
set STUB_DIR=samples\server\petstore\go-api-server

echo Removing files and folders under %STUB_DIR%
del /F /S /Q %STUB_DIR%
del /F /S /Q %STUB_DIR%\go

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

java %JAVA_OPTS% -jar %executable% %ags%

endlocal
endlocal
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@
</property>
</activation>
<modules>
<module>samples/server/petstore/go-api-server</module>
<module>samples/server/petstore/go-gin-api-server</module>
<!-- clients -->
<module>samples/openapi3/client/petstore/ruby</module>
<!-- test java-related projects -->
Expand Down
61 changes: 61 additions & 0 deletions samples/server/petstore/go-api-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>GoApiServer</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>Go Api Server</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>gofmt-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>gofmt</executable>
<arguments>
<argument>-w</argument>
<argument>./main.go</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>gofmt-file-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>gofmt</executable>
<arguments>
<argument>-w</argument>
<argument>./go/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
61 changes: 61 additions & 0 deletions samples/server/petstore/go-gin-api-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>GoGinServer</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>Go Gin Server</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>gofmt-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>gofmt</executable>
<arguments>
<argument>-w</argument>
<argument>./main.go</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>gofmt-file-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>gofmt</executable>
<arguments>
<argument>-w</argument>
<argument>./go/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 5dcde3f

Please sign in to comment.