Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More mangling for generated package names and path #1804

Merged
merged 1 commit into from
Nov 19, 2018

Conversation

fredbi
Copy link
Contributor

@fredbi fredbi commented Nov 18, 2018

Makes generation functional and consistent regarding:

Signed-off-by: Frederic BIDON fredbi@yahoo.com

@@ -458,6 +458,44 @@ func TestShared_MangleFileName(t *testing.T) {
assert.True(t, strings.HasSuffix(res, "_test_swagger"))
}

func TestShared_ManglePackagePath(t *testing.T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

461-478 lines are duplicate of generator/shared_test.go:480-497

assert.Equal(t, "a/b/c-d/e_f/g_h", res)
}

func TestShared_ManglePackageName(t *testing.T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

480-497 lines are duplicate of generator/shared_test.go:461-478

"testing"

"github.com/stretchr/testify/assert"
)

func testClientGenOpts() (g GenOpts) {
g.Target = "."
g.APIPackage = "operations"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string operations has 2 occurrences, make it a constant

g.APIPackage = "operations"
g.ModelPackage = "models"
g.ServerPackage = "restapi"
g.ClientPackage = "client"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string client has 2 occurrences, make it a constant

assert.Error(t, err)

opts = testClientGenOpts()
opts.Spec = "../fixtures/petstores/petstore.json"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string ../fixtures/petstores/petstore.json has 2 occurrences, make it a constant

g.Target = "."
g.APIPackage = "operations"
g.ModelPackage = "models"
g.ServerPackage = "restapi"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string restapi has 2 occurrences, make it a constant

func testClientGenOpts() (g GenOpts) {
g.Target = "."
g.APIPackage = "operations"
g.ModelPackage = "models"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string models has 4 occurrences, make it a constant

@fredbi
Copy link
Contributor Author

fredbi commented Nov 18, 2018

@MrLuje this is supposed to supersede your #1790 with more complete coverage. Feel free to check it out.

@codecov
Copy link

codecov bot commented Nov 18, 2018

Codecov Report

Merging #1804 into master will increase coverage by 0.33%.
The diff coverage is 96.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1804      +/-   ##
==========================================
+ Coverage   80.07%   80.41%   +0.33%     
==========================================
  Files          38       38              
  Lines        7494     7521      +27     
==========================================
+ Hits         6001     6048      +47     
+ Misses       1014     1000      -14     
+ Partials      479      473       -6
Impacted Files Coverage Δ
generator/operation.go 89.36% <100%> (+0.03%) ⬆️
generator/bindata.go 68.34% <100%> (ø) ⬆️
generator/template_repo.go 87.79% <100%> (+0.35%) ⬆️
generator/model.go 84.32% <100%> (ø) ⬆️
cmd/swagger/commands/generate/client.go 100% <100%> (ø) ⬆️
generator/client.go 80.19% <91.66%> (+12.01%) ⬆️
generator/support.go 89.05% <93.54%> (-0.29%) ⬇️
generator/shared.go 82.29% <97.05%> (+1.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f7a333...2b5c275. Read the comment docs.

Makes generation functional and consistent regarding:
* dashes in names
* reserved suffixes, which are meaningful for go, like 'test'
* sub-directories specified as target names (e.g. 'api/subdir')
* packages for client, model and server

* fixes go-swagger#1683
* fixes go-swagger#1157
* fixes go-swagger#1624

* replaces go-swagger#1790

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@casualjim casualjim merged commit df5b513 into go-swagger:master Nov 19, 2018
fredbi added a commit to fredbi/go-swagger that referenced this pull request Nov 20, 2018
* fixes go-swagger#1808

Thanks to @MrLuje for uncovering this issue.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit to fredbi/go-swagger that referenced this pull request Nov 20, 2018
* fixes go-swagger#1808

Thanks to @MrLuje for uncovering this issue.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
casualjim added a commit that referenced this pull request Nov 20, 2018
Fixed regression on Windows introduced by #1804
@fredbi fredbi deleted the fix-1683 branch November 22, 2018 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants