[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
This commit is contained in:
William Cheng 2019-10-29 15:15:24 +08:00 committed by GitHub
parent 28a87b0bde
commit 5dcde3f855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 136 additions and 8 deletions

View File

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

View File

@ -29,8 +29,8 @@ 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"
@ -38,4 +38,3 @@ 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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