[Lua] Improve auto-generated test files (#7568)

* move lua spec folder, remove extra endline

* remove extra line

* remove duplicated import
This commit is contained in:
William Cheng 2018-02-04 22:06:43 +08:00 committed by GitHub
parent 6c79052ac4
commit dbe78e23e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 90 additions and 118 deletions

View File

@ -285,12 +285,12 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public String apiTestFileFolder() { public String apiTestFileFolder() {
return outputFolder + File.separator + apiPackage + File.separator + specFolder.replace("/", File.separator); return outputFolder + File.separator + specFolder.replace("/", File.separator);
} }
@Override @Override
public String modelTestFileFolder() { public String modelTestFileFolder() {
return outputFolder + File.separator + modelPackage + File.separator + specFolder.replace("/", File.separator); return outputFolder + File.separator + specFolder.replace("/", File.separator);
} }
@Override @Override

View File

@ -1,15 +1,4 @@
--[[
{{> partial_header}} {{> partial_header}}
]]
local petstore_{{classname}} = require "{{packageName}}.api.{{{classname}}}"
{{#models}}
[[-- import all models --]]
{{#model}}
local {{packageName}}_{{{classname}}} = require "{{packageName}}.model.{{{classname}}}"
{{/model}}
{{/models}}
--[[ --[[
Unit tests for {{{packageName}}}.api.{{{classname}}} Unit tests for {{{packageName}}}.api.{{{classname}}}
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
@ -17,9 +6,16 @@ Please update as you see appropriate
]] ]]
{{#operations}} {{#operations}}
describe("{{classname}}", function() describe("{{classname}}", function()
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.api.{{{classname}}}"
{{#operation}} {{#operation}}
{{#models}}
[[-- import all models --]]
{{#model}}
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.model.{{{classname}}}"
{{/model}}
{{/models}}
-- unit tests for {{operationId}} -- unit tests for {{operationId}}
describe("{{operationId}} test", function() describe("{{{operationId}}} test", function()
it("should work", function() it("should work", function()
-- TODO assertion here: http://olivinelabs.com/busted/#asserts -- TODO assertion here: http://olivinelabs.com/busted/#asserts
end) end)

View File

@ -1,17 +1,14 @@
--[[
{{> partial_header}} {{> partial_header}}
]]
{{#models}} {{#models}}
{{#model}} {{#model}}
local {{packageName}}_{{{classname}}} = require "{{packageName}}.model.{{{classname}}}"
--[[ --[[
Unit tests for {{{packageName}}}.model.{{{classname}}} Unit tests for {{{packageName}}}.model.{{{classname}}}
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("{{classname}}", function() describe("{{classname}}", function()
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.model.{{{classname}}}"
{{#vars}} {{#vars}}
-- unit tests for the property '{{{name}}}' -- unit tests for the property '{{{name}}}'
describe("property {{{name}}} test", function() describe("property {{{name}}} test", function()

View File

@ -1,23 +1,21 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_api_response = require "petstore.model.api_response"
--[[ --[[
Unit tests for petstore.model.api_response Unit tests for petstore.model.api_response
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("api_response", function() describe("api_response", function()
local petstore_api_response = require "petstore.model.api_response"
-- unit tests for the property 'code' -- unit tests for the property 'code'
describe("property code test", function() describe("property code test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,21 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_category = require "petstore.model.category"
--[[ --[[
Unit tests for petstore.model.category Unit tests for petstore.model.category
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("category", function() describe("category", function()
local petstore_category = require "petstore.model.category"
-- unit tests for the property 'id' -- unit tests for the property 'id'
describe("property id test", function() describe("property id test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,21 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_order = require "petstore.model.order"
--[[ --[[
Unit tests for petstore.model.order Unit tests for petstore.model.order
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("order", function() describe("order", function()
local petstore_order = require "petstore.model.order"
-- unit tests for the property 'id' -- unit tests for the property 'id'
describe("property id test", function() describe("property id test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,20 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_pet_api = require "petstore.api.pet_api"
--[[ --[[
Unit tests for petstore.api.pet_api Unit tests for petstore.api.pet_api
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("pet_api", function() describe("pet_api", function()
local petstore_pet_api = require "petstore.api.pet_api"
-- unit tests for add_pet -- unit tests for add_pet
describe("add_pet test", function() describe("add_pet test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,21 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_pet = require "petstore.model.pet"
--[[ --[[
Unit tests for petstore.model.pet Unit tests for petstore.model.pet
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("pet", function() describe("pet", function()
local petstore_pet = require "petstore.model.pet"
-- unit tests for the property 'id' -- unit tests for the property 'id'
describe("property id test", function() describe("property id test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,20 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_store_api = require "petstore.api.store_api"
--[[ --[[
Unit tests for petstore.api.store_api Unit tests for petstore.api.store_api
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("store_api", function() describe("store_api", function()
local petstore_store_api = require "petstore.api.store_api"
-- unit tests for delete_order -- unit tests for delete_order
describe("delete_order test", function() describe("delete_order test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,21 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_tag = require "petstore.model.tag"
--[[ --[[
Unit tests for petstore.model.tag Unit tests for petstore.model.tag
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("tag", function() describe("tag", function()
local petstore_tag = require "petstore.model.tag"
-- unit tests for the property 'id' -- unit tests for the property 'id'
describe("property id test", function() describe("property id test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,20 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_user_api = require "petstore.api.user_api"
--[[ --[[
Unit tests for petstore.api.user_api Unit tests for petstore.api.user_api
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("user_api", function() describe("user_api", function()
local petstore_user_api = require "petstore.api.user_api"
-- unit tests for create_user -- unit tests for create_user
describe("create_user test", function() describe("create_user test", function()
it("should work", function() it("should work", function()

View File

@ -1,23 +1,21 @@
--[[ --[[
Swagger Petstore Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.0-SNAPSHOT
]] ]]
local petstore_user = require "petstore.model.user"
--[[ --[[
Unit tests for petstore.model.user Unit tests for petstore.model.user
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
Please update as you see appropriate Please update as you see appropriate
]] ]]
describe("user", function() describe("user", function()
local petstore_user = require "petstore.model.user"
-- unit tests for the property 'id' -- unit tests for the property 'id'
describe("property id test", function() describe("property id test", function()
it("should work", function() it("should work", function()