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 172709d
Show file tree
Hide file tree
Showing 20 changed files with 722 additions and 1 deletion.
@@ -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
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)
}
18 changes: 18 additions & 0 deletions pkg/codegen/python/utilities_test.go
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,20 @@ 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) {
t.Parallel()
assert.Equal(t, tt.expected, pythonCase(tt.input))
})
}
}
Expand Up @@ -3,6 +3,7 @@
"_index.md",
"provider/_index.md",
"submodule1/_index.md",
"submodule1/fooencryptedbarclass/_index.md",
"submodule1/moduleresource/_index.md"
]
}
Expand Up @@ -13,6 +13,7 @@ Explore the resources and functions of the foo-bar.submodule1 module.

<h2 id="resources">Resources</h2>
<ul class="api">
<li><a href="fooencryptedbarclass" title="FOOEncryptedBarClass"><span class="api-symbol api-symbol--resource"></span>FOOEncryptedBarClass</a></li>
<li><a href="moduleresource" title="ModuleResource"><span class="api-symbol api-symbol--resource"></span>ModuleResource</a></li>
</ul>

Expand Down

0 comments on commit 172709d

Please sign in to comment.