mirror of
				https://github.com/OpenAPITools/openapi-generator.git
				synced 2025-11-03 18:23:44 +00:00 
			
		
		
		
	[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:
		
							parent
							
								
									28a87b0bde
								
							
						
					
					
						commit
						5dcde3f855
					
				@ -24,6 +24,10 @@ elif [ "$NODE_INDEX" = "2" ]; then
 | 
				
			|||||||
    # install elm-format
 | 
					    # install elm-format
 | 
				
			||||||
    npm install -g 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
 | 
					    ./bin/utils/ensure-up-to-date
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
#elif [ "$NODE_INDEX" = "3" ]; then
 | 
					#elif [ "$NODE_INDEX" = "3" ]; then
 | 
				
			||||||
 | 
				
			|||||||
@ -29,8 +29,8 @@ SPEC="modules/openapi-generator/src/test/resources/2_0/petstore.yaml"
 | 
				
			|||||||
GENERATOR="go-gin-server"
 | 
					GENERATOR="go-gin-server"
 | 
				
			||||||
STUB_DIR="samples/server/petstore/go-gin-api-server"
 | 
					STUB_DIR="samples/server/petstore/go-gin-api-server"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Removing files and folders under $STUB_DIR"
 | 
					echo "Removing auto-generated files and folders under $STUB_DIR"
 | 
				
			||||||
rm -rf $STUB_DIR
 | 
					rm -rf $STUB_DIR/go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if you've executed sbt assembly previously it will use that instead.
 | 
					# if you've executed sbt assembly previously it will use that instead.
 | 
				
			||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
					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 $@"
 | 
					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
 | 
					java $JAVA_OPTS -jar $executable $ags
 | 
				
			||||||
#!/usr/bin/env bash
 | 
					 | 
				
			||||||
@ -29,8 +29,8 @@ SPEC="modules/openapi-generator/src/test/resources/2_0/petstore.yaml"
 | 
				
			|||||||
GENERATOR="go-server"
 | 
					GENERATOR="go-server"
 | 
				
			||||||
STUB_DIR="samples/server/petstore/go-api-server"
 | 
					STUB_DIR="samples/server/petstore/go-api-server"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Removing files and folders under $STUB_DIR"
 | 
					echo "Removing auto-generated files and folders under $STUB_DIR"
 | 
				
			||||||
rm -rf $STUB_DIR
 | 
					rm -rf $STUB_DIR/go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if you've executed sbt assembly previously it will use that instead.
 | 
					# if you've executed sbt assembly previously it will use that instead.
 | 
				
			||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
					export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
				
			||||||
 | 
				
			|||||||
@ -61,6 +61,7 @@ declare -a scripts=(
 | 
				
			|||||||
"./bin/go-experimental-petstore.sh"
 | 
					"./bin/go-experimental-petstore.sh"
 | 
				
			||||||
"./bin/go-petstore.sh"
 | 
					"./bin/go-petstore.sh"
 | 
				
			||||||
"./bin/go-petstore-withxml.sh"
 | 
					"./bin/go-petstore-withxml.sh"
 | 
				
			||||||
 | 
					"./bin/go-petstore-server.sh"
 | 
				
			||||||
"./bin/go-gin-petstore-server.sh"
 | 
					"./bin/go-gin-petstore-server.sh"
 | 
				
			||||||
"./bin/groovy-petstore.sh"
 | 
					"./bin/groovy-petstore.sh"
 | 
				
			||||||
"./bin/apex-petstore.sh"
 | 
					"./bin/apex-petstore.sh"
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ set GENERATOR=go-gin-server
 | 
				
			|||||||
set STUB_DIR=samples\server\petstore\go-gin-api-server
 | 
					set STUB_DIR=samples\server\petstore\go-gin-api-server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo Removing files and folders under %STUB_DIR%
 | 
					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
 | 
					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
 | 
					set ags=generate -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstoreserver
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ set GENERATOR=go-server
 | 
				
			|||||||
set STUB_DIR=samples\server\petstore\go-api-server
 | 
					set STUB_DIR=samples\server\petstore\go-api-server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo Removing files and folders under %STUB_DIR%
 | 
					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
 | 
					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
 | 
					set ags=generate -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstoreserver
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							@ -1183,6 +1183,8 @@
 | 
				
			|||||||
                </property>
 | 
					                </property>
 | 
				
			||||||
            </activation>
 | 
					            </activation>
 | 
				
			||||||
            <modules>
 | 
					            <modules>
 | 
				
			||||||
 | 
					                <module>samples/server/petstore/go-api-server</module>
 | 
				
			||||||
 | 
					                <module>samples/server/petstore/go-gin-api-server</module>
 | 
				
			||||||
                <!-- clients -->
 | 
					                <!-- clients -->
 | 
				
			||||||
                <module>samples/openapi3/client/petstore/ruby</module>
 | 
					                <module>samples/openapi3/client/petstore/ruby</module>
 | 
				
			||||||
                <!-- test java-related projects -->
 | 
					                <!-- test java-related projects -->
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										61
									
								
								samples/server/petstore/go-api-server/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								samples/server/petstore/go-api-server/pom.xml
									
									
									
									
									
										Normal 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>
 | 
				
			||||||
							
								
								
									
										61
									
								
								samples/server/petstore/go-gin-api-server/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								samples/server/petstore/go-gin-api-server/pom.xml
									
									
									
									
									
										Normal 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>
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user