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: Functions sdk update #3254

Merged
merged 64 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b5d5673
functions SDK update starts here
sfc-gh-asawicki Dec 5, 2024
4e6f7ad
Add TODOs for create
sfc-gh-asawicki Dec 5, 2024
70f697f
Modify opts impl template in generator to reduce whitespace
sfc-gh-asawicki Dec 5, 2024
42fb768
Regenerate to replace struct creation
sfc-gh-asawicki Dec 5, 2024
5211af8
Update TODOs
sfc-gh-asawicki Dec 5, 2024
8a94f3c
Remove single quotes from AS and add AGGREGATE for python (WIP)
sfc-gh-asawicki Dec 5, 2024
fec412b
Add mapping from function detail row to properties and start function…
sfc-gh-asawicki Dec 5, 2024
a53949d
Add describe details func
sfc-gh-asawicki Dec 5, 2024
2459bc3
Generate snowflake object assertions for functions (in current shape)
sfc-gh-asawicki Dec 5, 2024
32eea23
Extract sample function definitions in different languages
sfc-gh-asawicki Dec 5, 2024
9d48ab6
Extract identity function
sfc-gh-asawicki Dec 5, 2024
d00002b
Add minimal set of creation tests to implement
sfc-gh-asawicki Dec 5, 2024
3992634
Remove TODO
sfc-gh-asawicki Dec 6, 2024
14e5136
Fix python procedure
sfc-gh-asawicki Dec 6, 2024
25f8ab8
Go through existing TODOs in definition with manual tests
sfc-gh-asawicki Dec 6, 2024
bbac373
Add target
sfc-gh-asawicki Dec 6, 2024
2a1f707
Returned details for different types of functions
sfc-gh-asawicki Dec 6, 2024
3a00577
Update a few comments with knowledge
sfc-gh-asawicki Dec 6, 2024
287ffc5
Check weird names
sfc-gh-asawicki Dec 6, 2024
a80bdc4
Set double quotes in argument names
sfc-gh-asawicki Dec 6, 2024
f82e434
Add mapping to describe options
sfc-gh-asawicki Dec 6, 2024
a59b407
Move TODOs before regeneration
sfc-gh-asawicki Dec 6, 2024
485726d
Update alter for functions
sfc-gh-asawicki Dec 6, 2024
36f01e7
Regenerate functions (WIP - no test/compilation)
sfc-gh-asawicki Dec 6, 2024
db226a6
Reorganize, Rename, and Pass unit tests
sfc-gh-asawicki Dec 6, 2024
a56e644
Test empty and non-empty secrets
sfc-gh-asawicki Dec 6, 2024
2b3ce4b
Fix secret reference
sfc-gh-asawicki Dec 7, 2024
0b7d036
Finish describe mapping
sfc-gh-asawicki Dec 7, 2024
92b0f1d
Add parameters to each create
sfc-gh-asawicki Dec 7, 2024
d5487fb
Pass first integration tests
sfc-gh-asawicki Dec 7, 2024
ea9b33e
Extend java inline function creation
sfc-gh-asawicki Dec 7, 2024
8a17749
Add describe assertions
sfc-gh-asawicki Dec 7, 2024
c3a3b59
Add function parameters definition
sfc-gh-asawicki Dec 7, 2024
bc6ebfe
Add function parameters assertions and helpers
sfc-gh-asawicki Dec 7, 2024
9b0b55d
Check function parameters in tests
sfc-gh-asawicki Dec 7, 2024
93f7e77
Add minimal test for staged java func
sfc-gh-asawicki Dec 7, 2024
414be6c
Extract function stored in jar setup
sfc-gh-asawicki Dec 7, 2024
77145ba
Check import in inline function too
sfc-gh-asawicki Dec 7, 2024
e267caa
Test java full staged
sfc-gh-asawicki Dec 8, 2024
b811ab8
Pass javascript function creation tests
sfc-gh-asawicki Dec 8, 2024
fbbdd6e
Provide a quick way to speed up local testing
sfc-gh-asawicki Dec 8, 2024
03c048f
Pass python inline minimal
sfc-gh-asawicki Dec 8, 2024
443bf80
Pass python inline full
sfc-gh-asawicki Dec 8, 2024
7da9a7f
Pass python inline full with import
sfc-gh-asawicki Dec 8, 2024
29d3718
Test python staged (both options)
sfc-gh-asawicki Dec 8, 2024
ee5886a
Test scala inline (both options)
sfc-gh-asawicki Dec 8, 2024
616e0c3
Test scala staged (both options)
sfc-gh-asawicki Dec 8, 2024
4971287
Add secrets and external access integrations to scala functions
sfc-gh-asawicki Dec 8, 2024
e3c6e36
Test create SQL func minimal
sfc-gh-asawicki Dec 8, 2024
22935c2
Test create SQL func full
sfc-gh-asawicki Dec 8, 2024
905ecf3
Test create SQL without args
sfc-gh-asawicki Dec 8, 2024
cb51f3e
Add a TODO
sfc-gh-asawicki Dec 8, 2024
9d5ff09
Start testing alters
sfc-gh-asawicki Dec 8, 2024
e24a38d
Add describe assertions
sfc-gh-asawicki Dec 8, 2024
1bb7685
Pass function integration tests
sfc-gh-asawicki Dec 8, 2024
3b686f4
Fix runtime version for scala and add missing show outputs
sfc-gh-asawicki Dec 8, 2024
3f37bd9
Solve TODOs
sfc-gh-asawicki Dec 8, 2024
474e42d
Remove target path in appropriate tests
sfc-gh-asawicki Dec 8, 2024
b5123b1
Clean up TODOs
sfc-gh-asawicki Dec 8, 2024
086e202
Run pre-push
sfc-gh-asawicki Dec 8, 2024
e97df58
Fix cleanup
sfc-gh-asawicki Dec 8, 2024
503e095
Fix function resource
sfc-gh-asawicki Dec 8, 2024
383d219
Merge branch 'main' into functions-sdk-update
sfc-gh-asawicki Dec 9, 2024
7a392ec
Fix acceptance test
sfc-gh-asawicki Dec 9, 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
@@ -0,0 +1,370 @@
package objectassert

import (
"fmt"
"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/sdk"
)

// TODO [SNOW-1501905]: this file should be fully regenerated when adding and option to assert the results of describe
type FunctionDetailsAssert struct {
*assert.SnowflakeObjectAssert[sdk.FunctionDetails, sdk.SchemaObjectIdentifierWithArguments]
}

func FunctionDetails(t *testing.T, id sdk.SchemaObjectIdentifierWithArguments) *FunctionDetailsAssert {
t.Helper()
return &FunctionDetailsAssert{
assert.NewSnowflakeObjectAssertWithProvider(sdk.ObjectType("FUNCTION_DETAILS"), id, acc.TestClient().Function.DescribeDetails),
}
}

func (f *FunctionDetailsAssert) HasSignature(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Signature != expected {
return fmt.Errorf("expected signature: %v; got: %v", expected, o.Signature)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasReturns(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Returns != expected {
return fmt.Errorf("expected returns: %v; got: %v", expected, o.Returns)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasLanguage(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Language != expected {
return fmt.Errorf("expected language: %v; got: %v", expected, o.Language)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasBody(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Body == nil {
return fmt.Errorf("expected body to have value; got: nil")
}
if *o.Body != expected {
return fmt.Errorf("expected body: %v; got: %v", expected, *o.Body)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasNullHandling(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.NullHandling == nil {
return fmt.Errorf("expected null handling to have value; got: nil")
}
if *o.NullHandling != expected {
return fmt.Errorf("expected null handling: %v; got: %v", expected, *o.NullHandling)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasVolatility(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Volatility == nil {
return fmt.Errorf("expected volatility to have value; got: nil")
}
if *o.Volatility != expected {
return fmt.Errorf("expected volatility: %v; got: %v", expected, *o.Volatility)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasExternalAccessIntegrations(expected string) *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")
}
if *o.ExternalAccessIntegrations != expected {
return fmt.Errorf("expected external access integrations: %v; got: %v", expected, *o.ExternalAccessIntegrations)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasSecrets(expected string) *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")
}
if *o.Secrets != expected {
return fmt.Errorf("expected secrets: %v; got: %v", expected, *o.Secrets)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasImports(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Imports == nil {
return fmt.Errorf("expected imports to have value; got: nil")
}
if *o.Imports != expected {
return fmt.Errorf("expected imports: %v; got: %v", expected, *o.Imports)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasHandler(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Handler == nil {
return fmt.Errorf("expected handler to have value; got: nil")
}
if *o.Handler != expected {
return fmt.Errorf("expected handler: %v; got: %v", expected, *o.Handler)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasRuntimeVersion(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.RuntimeVersion == nil {
return fmt.Errorf("expected runtime version to have value; got: nil")
}
if *o.RuntimeVersion != expected {
return fmt.Errorf("expected runtime version: %v; got: %v", expected, *o.RuntimeVersion)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasPackages(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Packages == nil {
return fmt.Errorf("expected packages to have value; got: nil")
}
if *o.Packages != expected {
return fmt.Errorf("expected packages: %v; got: %v", expected, *o.Packages)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasTargetPath(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.TargetPath == nil {
return fmt.Errorf("expected target path to have value; got: nil")
}
if *o.TargetPath != expected {
return fmt.Errorf("expected target path: %v; got: %v", expected, *o.TargetPath)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasInstalledPackages(expected string) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.InstalledPackages == nil {
return fmt.Errorf("expected installed packages to have value; got: nil")
}
if *o.InstalledPackages != expected {
return fmt.Errorf("expected installed packages: %v; got: %v", expected, *o.InstalledPackages)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasIsAggregate(expected bool) *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.IsAggregate == nil {
return fmt.Errorf("expected is aggregate to have value; got: nil")
}
if *o.IsAggregate != expected {
return fmt.Errorf("expected is aggregate: %v; got: %v", expected, *o.IsAggregate)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasBodyNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Body != nil {
return fmt.Errorf("expected body to be nil, was %v", *o.Body)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasNullHandlingNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.NullHandling != nil {
return fmt.Errorf("expected null handling to be nil, was %v", *o.NullHandling)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasVolatilityNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Volatility != nil {
return fmt.Errorf("expected volatility to be nil, was %v", *o.Volatility)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasExternalAccessIntegrationsNil() *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 be nil, was %v", *o.ExternalAccessIntegrations)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasSecretsNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Secrets != nil {
return fmt.Errorf("expected secrets to be nil, was %v", *o.Secrets)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasImportsNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Imports != nil {
return fmt.Errorf("expected imports to be nil, was %v", *o.Imports)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasHandlerNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Handler != nil {
return fmt.Errorf("expected handler to be nil, was %v", *o.Handler)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasRuntimeVersionNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.RuntimeVersion != nil {
return fmt.Errorf("expected runtime version to be nil, was %v", *o.RuntimeVersion)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasPackagesNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.Packages != nil {
return fmt.Errorf("expected packages to be nil, was %v", *o.Packages)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasTargetPathNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.TargetPath != nil {
return fmt.Errorf("expected target path to be nil, was %v", *o.TargetPath)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasInstalledPackagesNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.InstalledPackages != nil {
return fmt.Errorf("expected installed packages to be nil, was %v", *o.InstalledPackages)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasIsAggregateNil() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.IsAggregate != nil {
return fmt.Errorf("expected is aggregate to be nil, was %v", *o.IsAggregate)
}
return nil
})
return f
}

func (f *FunctionDetailsAssert) HasInstalledPackagesNotEmpty() *FunctionDetailsAssert {
f.AddAssertion(func(t *testing.T, o *sdk.FunctionDetails) error {
t.Helper()
if o.InstalledPackages == nil {
return fmt.Errorf("expected installed packages to not be nil")
}
if *o.InstalledPackages == "" {
return fmt.Errorf("expected installed packages to not be empty")
}
return nil
})
return f
}
Loading
Loading