Skip to content

Commit

Permalink
Don't remove existing capitals in python names
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Oct 17, 2022
1 parent cf8e8f1 commit 805044c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: sdkgen/go,python
description: Handle hypheneated names in go and python
2 changes: 1 addition & 1 deletion pkg/codegen/python/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ func pythonCase(s string) string {
underscores += "_"
return true
})
c := cgstrings.Camel(noUnderscores)
c := cgstrings.Unhyphenate(noUnderscores)
return underscores + cgstrings.UppercaseFirst(c)
}
17 changes: 17 additions & 0 deletions pkg/codegen/python/utilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/blang/semver"
"github.com/stretchr/testify/assert"

"github.com/hashicorp/hcl/v2"
"github.com/pulumi/pulumi/pkg/v3/codegen/hcl2/syntax"
Expand Down Expand Up @@ -101,3 +102,19 @@ func TestMakePyPiVersion(t *testing.T) {
})
}
}

func TestPythonCase(t *testing.T) {
t.Parallel()

tests := []struct{ input, expected string }{
{"FOOBarInput", "FOOBarInput"},
{"foo-bar", "FooBar"},
}

for _, tt := range tests {
tt := tt
t.Run(tt.input, func(t *testing.T) {
assert.Equal(t, tt.expected, pythonCase(tt.input))
})
}
}

0 comments on commit 805044c

Please sign in to comment.