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

feat: Procedures sdk update #3255

Merged
merged 31 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fa3e3b9
procedures SDK update starts here
sfc-gh-asawicki Dec 8, 2024
e4a2837
Rename main procedure integration test
sfc-gh-asawicki Dec 8, 2024
7311812
Add procedure parameters, assertions, and missing enum
sfc-gh-asawicki Dec 8, 2024
2be47af
Update procedure definition
sfc-gh-asawicki Dec 8, 2024
cbbe0bf
Prepare procedure details
sfc-gh-asawicki Dec 8, 2024
f64cc09
Add wrapping to procedure bodies
sfc-gh-asawicki Dec 8, 2024
2f11fc3
Fix procedure impl
sfc-gh-asawicki Dec 8, 2024
bca99de
Regenerate procedures - validations ready
sfc-gh-asawicki Dec 8, 2024
ce3b8d0
Regenerate procedures - every file besides unit tests
sfc-gh-asawicki Dec 8, 2024
c221248
Update procedure unit tests
sfc-gh-asawicki Dec 8, 2024
b535a53
Generate object assertions for procedures
sfc-gh-asawicki Dec 8, 2024
78b85f4
Add procedure details assertions
sfc-gh-asawicki Dec 8, 2024
68fc2a7
Pass integration test for procedure
sfc-gh-asawicki Dec 8, 2024
ecf5362
Pass integration test for full inline java procedure
sfc-gh-asawicki Dec 8, 2024
8f1c7c8
Introduce proper ordering for null input behavior
sfc-gh-asawicki Dec 8, 2024
322dc1d
Test java staged procedures
sfc-gh-asawicki Dec 9, 2024
87e6321
Test javascript procedure creation
sfc-gh-asawicki Dec 9, 2024
77cfa05
Add tests for python, scala, and SQL
sfc-gh-asawicki Dec 9, 2024
1d6d67f
Skip old tests
sfc-gh-asawicki Dec 9, 2024
d5f6359
Pass alter, describe, and drop tests
sfc-gh-asawicki Dec 9, 2024
df81993
Pass show tests
sfc-gh-asawicki Dec 9, 2024
2073a57
Fill out TODO
sfc-gh-asawicki Dec 9, 2024
ef6d5dd
Fix test
sfc-gh-asawicki Dec 9, 2024
9893268
Run pre-push
sfc-gh-asawicki Dec 9, 2024
85045db
Remove done todo
sfc-gh-asawicki Dec 9, 2024
b825418
Add todos from the review comments
sfc-gh-asawicki Dec 9, 2024
aaa97ec
Fix function and procedure resources
sfc-gh-asawicki Dec 9, 2024
ffe8395
Add better assertions for external access integrations and secrets
sfc-gh-asawicki Dec 10, 2024
f21c3a3
Fix after review and fix tests
sfc-gh-asawicki Dec 10, 2024
d39a768
Fix create and call procedure (quickfix)
sfc-gh-asawicki Dec 10, 2024
152f7b6
Fix temporary
sfc-gh-asawicki Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package objectassert

import (
"fmt"
"strings"
"testing"

acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
)

Expand Down Expand Up @@ -368,3 +370,38 @@ func (f *FunctionDetailsAssert) HasInstalledPackagesNotEmpty() *FunctionDetailsA
})
return f
}

func (f *FunctionDetailsAssert) HasExactlyExternalAccessIntegrations(integrations ...sdk.AccountObjectIdentifier) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.ExternalAccessIntegrations == nil {
return fmt.Errorf("expected external access integrations to have value; got: nil")
}
joined := strings.Join(collections.Map(integrations, func(ex sdk.AccountObjectIdentifier) string { return ex.FullyQualifiedName() }), ",")
expected := fmt.Sprintf(`[%s]`, joined)
if *o.ExternalAccessIntegrations != expected {
return fmt.Errorf("expected external access integrations: %v; got: %v", expected, *o.ExternalAccessIntegrations)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasExactlySecrets(expectedSecrets map[string]sdk.SchemaObjectIdentifier) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Secrets == nil {
return fmt.Errorf("expected secrets to have value; got: nil")
}
var parts []string
for k, v := range expectedSecrets {
parts = append(parts, fmt.Sprintf(`"%s":"\"%s\".\"%s\".%s"`, k, v.DatabaseName(), v.SchemaName(), v.Name()))
}
expected := fmt.Sprintf(`{%s}`, strings.Join(parts, ","))
if *o.Secrets != expected {
return fmt.Errorf("expected secrets: %v; got: %v", expected, *o.Secrets)
}
return nil
})
return f
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package objectassert

import (
"fmt"
"strings"
"testing"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
)

Expand All @@ -28,3 +30,38 @@ func (a *FunctionAssert) HasExternalAccessIntegrationsNil() *FunctionAssert {
})
return a
}

func (f *FunctionAssert) HasExactlyExternalAccessIntegrations(integrations ...sdk.AccountObjectIdentifier) *FunctionAssert {
f.AddAssertion(func(t *testing.T, o *sdk.Function) error {
t.Helper()
if o.ExternalAccessIntegrations == nil {
return fmt.Errorf("expected external access integrations to have value; got: nil")
}
joined := strings.Join(collections.Map(integrations, func(ex sdk.AccountObjectIdentifier) string { return ex.FullyQualifiedName() }), ",")
expected := fmt.Sprintf(`[%s]`, joined)
if *o.ExternalAccessIntegrations != expected {
return fmt.Errorf("expected external access integrations: %v; got: %v", expected, *o.ExternalAccessIntegrations)
}
return nil
})
return f
}

func (f *FunctionAssert) HasExactlySecrets(expectedSecrets map[string]sdk.SchemaObjectIdentifier) *FunctionAssert {
f.AddAssertion(func(t *testing.T, o *sdk.Function) error {
t.Helper()
if o.Secrets == nil {
return fmt.Errorf("expected secrets to have value; got: nil")
}
var parts []string
for k, v := range expectedSecrets {
parts = append(parts, fmt.Sprintf(`"%s":"\"%s\".\"%s\".%s"`, k, v.DatabaseName(), v.SchemaName(), v.Name()))
}
expected := fmt.Sprintf(`{%s}`, strings.Join(parts, ","))
if *o.Secrets != expected {
return fmt.Errorf("expected secrets: %v; got: %v", expected, *o.Secrets)
}
return nil
})
return f
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ var allStructs = []SdkObjectDef{
ObjectType: sdk.ObjectTypeFunction,
ObjectStruct: sdk.Function{},
},
{
IdType: "sdk.SchemaObjectIdentifierWithArguments",
ObjectType: sdk.ObjectTypeProcedure,
ObjectStruct: sdk.Procedure{},
},
}

func GetSdkObjectDetails() []genhelpers.SdkObjectDetails {
Expand Down
Loading
Loading