Add tests
This commit is contained in:
parent
e01755f16a
commit
700e5cbca3
10
pkg/codegen/internal/test/testdata/regress-8403/go/codegen-manifest.json
vendored
Normal file
10
pkg/codegen/internal/test/testdata/regress-8403/go/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"mongodbatlas/doc.go",
|
||||
"mongodbatlas/getCustomDbRoles.go",
|
||||
"mongodbatlas/init.go",
|
||||
"mongodbatlas/provider.go",
|
||||
"mongodbatlas/pulumiTypes.go",
|
||||
"mongodbatlas/pulumiUtilities.go"
|
||||
]
|
||||
}
|
3
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/doc.go
vendored
Normal file
3
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/doc.go
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Package mongodbatlas exports types, functions, subpackages for provisioning mongodbatlas resources.
|
||||
//
|
||||
package mongodbatlas
|
24
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/getCustomDbRoles.go
vendored
Normal file
24
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/getCustomDbRoles.go
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mongodbatlas
|
||||
|
||||
import (
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
func LookupCustomDbRoles(ctx *pulumi.Context, args *LookupCustomDbRolesArgs, opts ...pulumi.InvokeOption) (*LookupCustomDbRolesResult, error) {
|
||||
var rv LookupCustomDbRolesResult
|
||||
err := ctx.Invoke("mongodbatlas::getCustomDbRoles", args, &rv, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rv, nil
|
||||
}
|
||||
|
||||
type LookupCustomDbRolesArgs struct {
|
||||
}
|
||||
|
||||
type LookupCustomDbRolesResult struct {
|
||||
Result *GetCustomDbRolesResult `pulumi:"result"`
|
||||
}
|
40
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/init.go
vendored
Normal file
40
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/init.go
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mongodbatlas
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type pkg struct {
|
||||
version semver.Version
|
||||
}
|
||||
|
||||
func (p *pkg) Version() semver.Version {
|
||||
return p.version
|
||||
}
|
||||
|
||||
func (p *pkg) ConstructProvider(ctx *pulumi.Context, name, typ, urn string) (pulumi.ProviderResource, error) {
|
||||
if typ != "pulumi:providers:mongodbatlas" {
|
||||
return nil, fmt.Errorf("unknown provider type: %s", typ)
|
||||
}
|
||||
|
||||
r := &Provider{}
|
||||
err := ctx.RegisterResource(typ, name, nil, r, pulumi.URN_(urn))
|
||||
return r, err
|
||||
}
|
||||
|
||||
func init() {
|
||||
version, err := PkgVersion()
|
||||
if err != nil {
|
||||
fmt.Printf("failed to determine package version. defaulting to v1: %v\n", err)
|
||||
}
|
||||
pulumi.RegisterResourcePackage(
|
||||
"mongodbatlas",
|
||||
&pkg{version},
|
||||
)
|
||||
}
|
79
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/provider.go
vendored
Normal file
79
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/provider.go
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mongodbatlas
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type Provider struct {
|
||||
pulumi.ProviderResourceState
|
||||
}
|
||||
|
||||
// NewProvider registers a new resource with the given unique name, arguments, and options.
|
||||
func NewProvider(ctx *pulumi.Context,
|
||||
name string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {
|
||||
if args == nil {
|
||||
args = &ProviderArgs{}
|
||||
}
|
||||
|
||||
var resource Provider
|
||||
err := ctx.RegisterResource("pulumi:providers:mongodbatlas", name, args, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
type providerArgs struct {
|
||||
}
|
||||
|
||||
// The set of arguments for constructing a Provider resource.
|
||||
type ProviderArgs struct {
|
||||
}
|
||||
|
||||
func (ProviderArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*providerArgs)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ProviderInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToProviderOutput() ProviderOutput
|
||||
ToProviderOutputWithContext(ctx context.Context) ProviderOutput
|
||||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
return i.ToProviderOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
|
||||
}
|
||||
|
||||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) ProviderOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterOutputType(ProviderOutput{})
|
||||
}
|
136
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/pulumiTypes.go
vendored
Normal file
136
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/pulumiTypes.go
vendored
Normal file
|
@ -0,0 +1,136 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mongodbatlas
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type GetCustomDbRolesResult struct {
|
||||
}
|
||||
|
||||
// GetCustomDbRolesResultInput is an input type that accepts GetCustomDbRolesResultArgs and GetCustomDbRolesResultOutput values.
|
||||
// You can construct a concrete instance of `GetCustomDbRolesResultInput` via:
|
||||
//
|
||||
// GetCustomDbRolesResultArgs{...}
|
||||
type GetCustomDbRolesResultInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToGetCustomDbRolesResultOutput() GetCustomDbRolesResultOutput
|
||||
ToGetCustomDbRolesResultOutputWithContext(context.Context) GetCustomDbRolesResultOutput
|
||||
}
|
||||
|
||||
type GetCustomDbRolesResultArgs struct {
|
||||
}
|
||||
|
||||
func (GetCustomDbRolesResultArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*GetCustomDbRolesResult)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i GetCustomDbRolesResultArgs) ToGetCustomDbRolesResultOutput() GetCustomDbRolesResultOutput {
|
||||
return i.ToGetCustomDbRolesResultOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i GetCustomDbRolesResultArgs) ToGetCustomDbRolesResultOutputWithContext(ctx context.Context) GetCustomDbRolesResultOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(GetCustomDbRolesResultOutput)
|
||||
}
|
||||
|
||||
func (i GetCustomDbRolesResultArgs) ToGetCustomDbRolesResultPtrOutput() GetCustomDbRolesResultPtrOutput {
|
||||
return i.ToGetCustomDbRolesResultPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i GetCustomDbRolesResultArgs) ToGetCustomDbRolesResultPtrOutputWithContext(ctx context.Context) GetCustomDbRolesResultPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(GetCustomDbRolesResultOutput).ToGetCustomDbRolesResultPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
// GetCustomDbRolesResultPtrInput is an input type that accepts GetCustomDbRolesResultArgs, GetCustomDbRolesResultPtr and GetCustomDbRolesResultPtrOutput values.
|
||||
// You can construct a concrete instance of `GetCustomDbRolesResultPtrInput` via:
|
||||
//
|
||||
// GetCustomDbRolesResultArgs{...}
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// nil
|
||||
type GetCustomDbRolesResultPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToGetCustomDbRolesResultPtrOutput() GetCustomDbRolesResultPtrOutput
|
||||
ToGetCustomDbRolesResultPtrOutputWithContext(context.Context) GetCustomDbRolesResultPtrOutput
|
||||
}
|
||||
|
||||
type getCustomDbRolesResultPtrType GetCustomDbRolesResultArgs
|
||||
|
||||
func GetCustomDbRolesResultPtr(v *GetCustomDbRolesResultArgs) GetCustomDbRolesResultPtrInput {
|
||||
return (*getCustomDbRolesResultPtrType)(v)
|
||||
}
|
||||
|
||||
func (*getCustomDbRolesResultPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**GetCustomDbRolesResult)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *getCustomDbRolesResultPtrType) ToGetCustomDbRolesResultPtrOutput() GetCustomDbRolesResultPtrOutput {
|
||||
return i.ToGetCustomDbRolesResultPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *getCustomDbRolesResultPtrType) ToGetCustomDbRolesResultPtrOutputWithContext(ctx context.Context) GetCustomDbRolesResultPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(GetCustomDbRolesResultPtrOutput)
|
||||
}
|
||||
|
||||
type GetCustomDbRolesResultOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (GetCustomDbRolesResultOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*GetCustomDbRolesResult)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o GetCustomDbRolesResultOutput) ToGetCustomDbRolesResultOutput() GetCustomDbRolesResultOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o GetCustomDbRolesResultOutput) ToGetCustomDbRolesResultOutputWithContext(ctx context.Context) GetCustomDbRolesResultOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o GetCustomDbRolesResultOutput) ToGetCustomDbRolesResultPtrOutput() GetCustomDbRolesResultPtrOutput {
|
||||
return o.ToGetCustomDbRolesResultPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o GetCustomDbRolesResultOutput) ToGetCustomDbRolesResultPtrOutputWithContext(ctx context.Context) GetCustomDbRolesResultPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v GetCustomDbRolesResult) *GetCustomDbRolesResult {
|
||||
return &v
|
||||
}).(GetCustomDbRolesResultPtrOutput)
|
||||
}
|
||||
|
||||
type GetCustomDbRolesResultPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (GetCustomDbRolesResultPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**GetCustomDbRolesResult)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o GetCustomDbRolesResultPtrOutput) ToGetCustomDbRolesResultPtrOutput() GetCustomDbRolesResultPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o GetCustomDbRolesResultPtrOutput) ToGetCustomDbRolesResultPtrOutputWithContext(ctx context.Context) GetCustomDbRolesResultPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o GetCustomDbRolesResultPtrOutput) Elem() GetCustomDbRolesResultOutput {
|
||||
return o.ApplyT(func(v *GetCustomDbRolesResult) GetCustomDbRolesResult {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret GetCustomDbRolesResult
|
||||
return ret
|
||||
}).(GetCustomDbRolesResultOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*GetCustomDbRolesResultInput)(nil)).Elem(), GetCustomDbRolesResultArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*GetCustomDbRolesResultPtrInput)(nil)).Elem(), GetCustomDbRolesResultArgs{})
|
||||
pulumi.RegisterOutputType(GetCustomDbRolesResultOutput{})
|
||||
pulumi.RegisterOutputType(GetCustomDbRolesResultPtrOutput{})
|
||||
}
|
85
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/pulumiUtilities.go
vendored
Normal file
85
pkg/codegen/internal/test/testdata/regress-8403/go/mongodbatlas/pulumiUtilities.go
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mongodbatlas
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type envParser func(v string) interface{}
|
||||
|
||||
func parseEnvBool(v string) interface{} {
|
||||
b, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func parseEnvInt(v string) interface{} {
|
||||
i, err := strconv.ParseInt(v, 0, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return int(i)
|
||||
}
|
||||
|
||||
func parseEnvFloat(v string) interface{} {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func parseEnvStringArray(v string) interface{} {
|
||||
var result pulumi.StringArray
|
||||
for _, item := range strings.Split(v, ";") {
|
||||
result = append(result, pulumi.String(item))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
|
||||
for _, v := range vars {
|
||||
if value := os.Getenv(v); value != "" {
|
||||
if parser != nil {
|
||||
return parser(value)
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
// PkgVersion uses reflection to determine the version of the current package.
|
||||
func PkgVersion() (semver.Version, error) {
|
||||
type sentinal struct{}
|
||||
pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
|
||||
re := regexp.MustCompile("^.*/pulumi-mongodbatlas/sdk(/v\\d+)?")
|
||||
if match := re.FindStringSubmatch(pkgPath); match != nil {
|
||||
vStr := match[1]
|
||||
if len(vStr) == 0 { // If the version capture group was empty, default to v1.
|
||||
return semver.Version{Major: 1}, nil
|
||||
}
|
||||
return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
|
||||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
22
pkg/codegen/internal/test/testdata/regress-8403/schema.json
vendored
Normal file
22
pkg/codegen/internal/test/testdata/regress-8403/schema.json
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"version": "0.0.1",
|
||||
"name": "mongodbatlas",
|
||||
"types": {
|
||||
"mongodbatlas::getCustomDbRolesResult": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"functions": {
|
||||
"mongodbatlas::getCustomDbRoles": {
|
||||
"inputs": {},
|
||||
"outputs": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"result": {
|
||||
"$ref": "#/types/mongodbatlas::getCustomDbRolesResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue