From a45ae5268e6bcd002a12e3f74809bfd77399095a Mon Sep 17 00:00:00 2001 From: Scott Winkler Date: Wed, 17 Jan 2024 23:23:30 -0800 Subject: [PATCH] update --- pkg/sdk/application_packages_def.go | 20 ++++--- .../application_packages_dto_builders_gen.go | 53 +++++++++++-------- pkg/sdk/application_packages_dto_gen.go | 38 +++++++------ pkg/sdk/application_packages_gen.go | 42 ++++++++------- pkg/sdk/application_packages_gen_test.go | 26 ++++++--- pkg/sdk/application_packages_impl_gen.go | 15 +++--- .../application_packages_validations_gen.go | 9 +++- .../application_packages_integration_test.go | 22 ++++---- 8 files changed, 136 insertions(+), 89 deletions(-) diff --git a/pkg/sdk/application_packages_def.go b/pkg/sdk/application_packages_def.go index 59491b12d1..ca64a270b5 100644 --- a/pkg/sdk/application_packages_def.go +++ b/pkg/sdk/application_packages_def.go @@ -42,6 +42,14 @@ var applicationPackageSet = g.NewQueryStruct("ApplicationPackageSet"). OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). PredefinedQueryStructField("Distribution", "*Distribution", g.ParameterOptions().SQL("DISTRIBUTION")) +var applicationPackageUnset = g.NewQueryStruct("ApplicationPackageUnset"). + OptionalSQL("DATA_RETENTION_TIME_IN_DAYS"). + OptionalSQL("MAX_DATA_EXTENSION_TIME_IN_DAYS"). + OptionalSQL("DEFAULT_DDL_COLLATION"). + OptionalSQL("COMMENT"). + OptionalSQL("DISTRIBUTION"). + WithValidation(g.ExactlyOneValueSet, "DataRetentionTimeInDays", "MaxDataExtensionTimeInDays", "DefaultDdlCollation", "Comment", "Distribution") + var ApplicationPackagesDef = g.NewInterface( "ApplicationPackages", "ApplicationPackage", @@ -72,11 +80,11 @@ var ApplicationPackagesDef = g.NewInterface( applicationPackageSet, g.KeywordOptions().SQL("SET"), ). - OptionalSQL("UNSET DATA_RETENTION_TIME_IN_DAYS"). - OptionalSQL("UNSET MAX_DATA_EXTENSION_TIME_IN_DAYS"). - OptionalSQL("UNSET DEFAULT_DDL_COLLATION"). - OptionalSQL("UNSET COMMENT"). - OptionalSQL("UNSET DISTRIBUTION"). + OptionalQueryStructField( + "Unset", + applicationPackageUnset, + g.KeywordOptions().SQL("UNSET"), + ). OptionalQueryStructField( "ModifyReleaseDirective", applicationPackageModifyReleaseDirective, @@ -115,7 +123,7 @@ var ApplicationPackagesDef = g.NewInterface( OptionalSetTags(). OptionalUnsetTags(). WithValidation(g.ValidIdentifier, "name"). - WithValidation(g.ExactlyOneValueSet, "Set", "UnsetDataRetentionTimeInDays", "UnsetMaxDataExtensionTimeInDays", "UnsetDefaultDdlCollation", "UnsetComment", "UnsetDistribution", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags"), + WithValidation(g.ExactlyOneValueSet, "Set", "Unset", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags"), ).DropOperation( "https://docs.snowflake.com/en/sql-reference/sql/drop-application-package", g.NewQueryStruct("DropApplicationPackage"). diff --git a/pkg/sdk/application_packages_dto_builders_gen.go b/pkg/sdk/application_packages_dto_builders_gen.go index 032e7b61ba..f2bf223034 100644 --- a/pkg/sdk/application_packages_dto_builders_gen.go +++ b/pkg/sdk/application_packages_dto_builders_gen.go @@ -65,28 +65,8 @@ func (s *AlterApplicationPackageRequest) WithSet(Set *ApplicationPackageSetReque return s } -func (s *AlterApplicationPackageRequest) WithUnsetDataRetentionTimeInDays(UnsetDataRetentionTimeInDays *bool) *AlterApplicationPackageRequest { - s.UnsetDataRetentionTimeInDays = UnsetDataRetentionTimeInDays - return s -} - -func (s *AlterApplicationPackageRequest) WithUnsetMaxDataExtensionTimeInDays(UnsetMaxDataExtensionTimeInDays *bool) *AlterApplicationPackageRequest { - s.UnsetMaxDataExtensionTimeInDays = UnsetMaxDataExtensionTimeInDays - return s -} - -func (s *AlterApplicationPackageRequest) WithUnsetDefaultDdlCollation(UnsetDefaultDdlCollation *bool) *AlterApplicationPackageRequest { - s.UnsetDefaultDdlCollation = UnsetDefaultDdlCollation - return s -} - -func (s *AlterApplicationPackageRequest) WithUnsetComment(UnsetComment *bool) *AlterApplicationPackageRequest { - s.UnsetComment = UnsetComment - return s -} - -func (s *AlterApplicationPackageRequest) WithUnsetDistribution(UnsetDistribution *bool) *AlterApplicationPackageRequest { - s.UnsetDistribution = UnsetDistribution +func (s *AlterApplicationPackageRequest) WithUnset(Unset *ApplicationPackageUnsetRequest) *AlterApplicationPackageRequest { + s.Unset = Unset return s } @@ -164,6 +144,35 @@ func (s *ApplicationPackageSetRequest) WithDistribution(Distribution *Distributi return s } +func NewApplicationPackageUnsetRequest() *ApplicationPackageUnsetRequest { + return &ApplicationPackageUnsetRequest{} +} + +func (s *ApplicationPackageUnsetRequest) WithDataRetentionTimeInDays(DataRetentionTimeInDays *bool) *ApplicationPackageUnsetRequest { + s.DataRetentionTimeInDays = DataRetentionTimeInDays + return s +} + +func (s *ApplicationPackageUnsetRequest) WithMaxDataExtensionTimeInDays(MaxDataExtensionTimeInDays *bool) *ApplicationPackageUnsetRequest { + s.MaxDataExtensionTimeInDays = MaxDataExtensionTimeInDays + return s +} + +func (s *ApplicationPackageUnsetRequest) WithDefaultDdlCollation(DefaultDdlCollation *bool) *ApplicationPackageUnsetRequest { + s.DefaultDdlCollation = DefaultDdlCollation + return s +} + +func (s *ApplicationPackageUnsetRequest) WithComment(Comment *bool) *ApplicationPackageUnsetRequest { + s.Comment = Comment + return s +} + +func (s *ApplicationPackageUnsetRequest) WithDistribution(Distribution *bool) *ApplicationPackageUnsetRequest { + s.Distribution = Distribution + return s +} + func NewModifyReleaseDirectiveRequest( ReleaseDirective string, Version string, diff --git a/pkg/sdk/application_packages_dto_gen.go b/pkg/sdk/application_packages_dto_gen.go index 5c23b0dbab..46e269097f 100644 --- a/pkg/sdk/application_packages_dto_gen.go +++ b/pkg/sdk/application_packages_dto_gen.go @@ -21,23 +21,19 @@ type CreateApplicationPackageRequest struct { } type AlterApplicationPackageRequest struct { - IfExists *bool - name AccountObjectIdentifier // required - Set *ApplicationPackageSetRequest - UnsetDataRetentionTimeInDays *bool - UnsetMaxDataExtensionTimeInDays *bool - UnsetDefaultDdlCollation *bool - UnsetComment *bool - UnsetDistribution *bool - ModifyReleaseDirective *ModifyReleaseDirectiveRequest - SetDefaultReleaseDirective *SetDefaultReleaseDirectiveRequest - SetReleaseDirective *SetReleaseDirectiveRequest - UnsetReleaseDirective *UnsetReleaseDirectiveRequest - AddVersion *AddVersionRequest - DropVersion *DropVersionRequest - AddPatchForVersion *AddPatchForVersionRequest - SetTags []TagAssociation - UnsetTags []ObjectIdentifier + IfExists *bool + name AccountObjectIdentifier // required + Set *ApplicationPackageSetRequest + Unset *ApplicationPackageUnsetRequest + ModifyReleaseDirective *ModifyReleaseDirectiveRequest + SetDefaultReleaseDirective *SetDefaultReleaseDirectiveRequest + SetReleaseDirective *SetReleaseDirectiveRequest + UnsetReleaseDirective *UnsetReleaseDirectiveRequest + AddVersion *AddVersionRequest + DropVersion *DropVersionRequest + AddPatchForVersion *AddPatchForVersionRequest + SetTags []TagAssociation + UnsetTags []ObjectIdentifier } type ApplicationPackageSetRequest struct { @@ -48,6 +44,14 @@ type ApplicationPackageSetRequest struct { Distribution *Distribution } +type ApplicationPackageUnsetRequest struct { + DataRetentionTimeInDays *bool + MaxDataExtensionTimeInDays *bool + DefaultDdlCollation *bool + Comment *bool + Distribution *bool +} + type ModifyReleaseDirectiveRequest struct { ReleaseDirective string // required Version string // required diff --git a/pkg/sdk/application_packages_gen.go b/pkg/sdk/application_packages_gen.go index 1ee06651df..e660bdafcc 100644 --- a/pkg/sdk/application_packages_gen.go +++ b/pkg/sdk/application_packages_gen.go @@ -29,25 +29,21 @@ type CreateApplicationPackageOptions struct { // AlterApplicationPackageOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-application-package. type AlterApplicationPackageOptions struct { - alter bool `ddl:"static" sql:"ALTER"` - applicationPackage bool `ddl:"static" sql:"APPLICATION PACKAGE"` - IfExists *bool `ddl:"keyword" sql:"IF EXISTS"` - name AccountObjectIdentifier `ddl:"identifier"` - Set *ApplicationPackageSet `ddl:"keyword" sql:"SET"` - UnsetDataRetentionTimeInDays *bool `ddl:"keyword" sql:"UNSET DATA_RETENTION_TIME_IN_DAYS"` - UnsetMaxDataExtensionTimeInDays *bool `ddl:"keyword" sql:"UNSET MAX_DATA_EXTENSION_TIME_IN_DAYS"` - UnsetDefaultDdlCollation *bool `ddl:"keyword" sql:"UNSET DEFAULT_DDL_COLLATION"` - UnsetComment *bool `ddl:"keyword" sql:"UNSET COMMENT"` - UnsetDistribution *bool `ddl:"keyword" sql:"UNSET DISTRIBUTION"` - ModifyReleaseDirective *ModifyReleaseDirective `ddl:"keyword" sql:"MODIFY RELEASE DIRECTIVE"` - SetDefaultReleaseDirective *SetDefaultReleaseDirective `ddl:"keyword" sql:"SET DEFAULT RELEASE DIRECTIVE"` - SetReleaseDirective *SetReleaseDirective `ddl:"keyword" sql:"SET RELEASE DIRECTIVE"` - UnsetReleaseDirective *UnsetReleaseDirective `ddl:"keyword" sql:"UNSET RELEASE DIRECTIVE"` - AddVersion *AddVersion `ddl:"keyword" sql:"ADD VERSION"` - DropVersion *DropVersion `ddl:"keyword" sql:"DROP VERSION"` - AddPatchForVersion *AddPatchForVersion `ddl:"keyword" sql:"ADD PATCH FOR VERSION"` - SetTags []TagAssociation `ddl:"keyword" sql:"SET TAG"` - UnsetTags []ObjectIdentifier `ddl:"keyword" sql:"UNSET TAG"` + alter bool `ddl:"static" sql:"ALTER"` + applicationPackage bool `ddl:"static" sql:"APPLICATION PACKAGE"` + IfExists *bool `ddl:"keyword" sql:"IF EXISTS"` + name AccountObjectIdentifier `ddl:"identifier"` + Set *ApplicationPackageSet `ddl:"keyword" sql:"SET"` + Unset *ApplicationPackageUnset `ddl:"keyword" sql:"UNSET"` + ModifyReleaseDirective *ModifyReleaseDirective `ddl:"keyword" sql:"MODIFY RELEASE DIRECTIVE"` + SetDefaultReleaseDirective *SetDefaultReleaseDirective `ddl:"keyword" sql:"SET DEFAULT RELEASE DIRECTIVE"` + SetReleaseDirective *SetReleaseDirective `ddl:"keyword" sql:"SET RELEASE DIRECTIVE"` + UnsetReleaseDirective *UnsetReleaseDirective `ddl:"keyword" sql:"UNSET RELEASE DIRECTIVE"` + AddVersion *AddVersion `ddl:"keyword" sql:"ADD VERSION"` + DropVersion *DropVersion `ddl:"keyword" sql:"DROP VERSION"` + AddPatchForVersion *AddPatchForVersion `ddl:"keyword" sql:"ADD PATCH FOR VERSION"` + SetTags []TagAssociation `ddl:"keyword" sql:"SET TAG"` + UnsetTags []ObjectIdentifier `ddl:"keyword" sql:"UNSET TAG"` } type ApplicationPackageSet struct { @@ -58,6 +54,14 @@ type ApplicationPackageSet struct { Distribution *Distribution `ddl:"parameter" sql:"DISTRIBUTION"` } +type ApplicationPackageUnset struct { + DataRetentionTimeInDays *bool `ddl:"keyword" sql:"DATA_RETENTION_TIME_IN_DAYS"` + MaxDataExtensionTimeInDays *bool `ddl:"keyword" sql:"MAX_DATA_EXTENSION_TIME_IN_DAYS"` + DefaultDdlCollation *bool `ddl:"keyword" sql:"DEFAULT_DDL_COLLATION"` + Comment *bool `ddl:"keyword" sql:"COMMENT"` + Distribution *bool `ddl:"keyword" sql:"DISTRIBUTION"` +} + type ModifyReleaseDirective struct { ReleaseDirective string `ddl:"keyword,no_quotes"` Version string `ddl:"parameter,no_quotes" sql:"VERSION"` diff --git a/pkg/sdk/application_packages_gen_test.go b/pkg/sdk/application_packages_gen_test.go index 795a52a570..0bfc3204fc 100644 --- a/pkg/sdk/application_packages_gen_test.go +++ b/pkg/sdk/application_packages_gen_test.go @@ -64,7 +64,7 @@ func TestApplicationPackages_Alter(t *testing.T) { t.Run("validation: exactly one field should be present", func(t *testing.T) { opts := defaultOpts() - assertOptsInvalidJoinedErrors(t, opts, errExactlyOneOf("AlterApplicationPackageOptions", "Set", "UnsetDataRetentionTimeInDays", "UnsetMaxDataExtensionTimeInDays", "UnsetDefaultDdlCollation", "UnsetComment", "UnsetDistribution", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags")) + assertOptsInvalidJoinedErrors(t, opts, errExactlyOneOf("AlterApplicationPackageOptions", "Set", "Unset", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags")) }) t.Run("validation: exactly one field should be present", func(t *testing.T) { @@ -76,7 +76,7 @@ func TestApplicationPackages_Alter(t *testing.T) { opts.UnsetReleaseDirective = &UnsetReleaseDirective{ ReleaseDirective: "DEFAULT", } - assertOptsInvalidJoinedErrors(t, opts, errExactlyOneOf("AlterApplicationPackageOptions", "Set", "UnsetDataRetentionTimeInDays", "UnsetMaxDataExtensionTimeInDays", "UnsetDefaultDdlCollation", "UnsetComment", "UnsetDistribution", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags")) + assertOptsInvalidJoinedErrors(t, opts, errExactlyOneOf("AlterApplicationPackageOptions", "Set", "Unset", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags")) }) t.Run("alter: set options", func(t *testing.T) { @@ -93,23 +93,33 @@ func TestApplicationPackages_Alter(t *testing.T) { t.Run("alter: unset options", func(t *testing.T) { opts := defaultOpts() - opts.UnsetComment = Bool(true) + opts.Unset = &ApplicationPackageUnset{ + Comment: Bool(true), + } assertOptsValidAndSQLEquals(t, opts, `ALTER APPLICATION PACKAGE IF EXISTS %s UNSET COMMENT`, id.FullyQualifiedName()) opts = defaultOpts() - opts.UnsetDataRetentionTimeInDays = Bool(true) + opts.Unset = &ApplicationPackageUnset{ + DataRetentionTimeInDays: Bool(true), + } assertOptsValidAndSQLEquals(t, opts, `ALTER APPLICATION PACKAGE IF EXISTS %s UNSET DATA_RETENTION_TIME_IN_DAYS`, id.FullyQualifiedName()) opts = defaultOpts() - opts.UnsetMaxDataExtensionTimeInDays = Bool(true) + opts.Unset = &ApplicationPackageUnset{ + MaxDataExtensionTimeInDays: Bool(true), + } assertOptsValidAndSQLEquals(t, opts, `ALTER APPLICATION PACKAGE IF EXISTS %s UNSET MAX_DATA_EXTENSION_TIME_IN_DAYS`, id.FullyQualifiedName()) opts = defaultOpts() - opts.UnsetDefaultDdlCollation = Bool(true) + opts.Unset = &ApplicationPackageUnset{ + DefaultDdlCollation: Bool(true), + } assertOptsValidAndSQLEquals(t, opts, `ALTER APPLICATION PACKAGE IF EXISTS %s UNSET DEFAULT_DDL_COLLATION`, id.FullyQualifiedName()) opts = defaultOpts() - opts.UnsetDistribution = Bool(true) + opts.Unset = &ApplicationPackageUnset{ + Distribution: Bool(true), + } assertOptsValidAndSQLEquals(t, opts, `ALTER APPLICATION PACKAGE IF EXISTS %s UNSET DISTRIBUTION`, id.FullyQualifiedName()) }) @@ -209,7 +219,7 @@ func TestApplicationPackages_Alter(t *testing.T) { Using: "@hello_snowflake_code.core.hello_snowflake_stage", Label: String("test"), } - assertOptsValidAndSQLEquals(t, opts, `ALTER APPLICATION PACKAGE IF EXISTS %s ADD PATCH FOR VERSION v1_1 USING '@hello_snowflake_code.core.hello_snowflake_stage' Label = 'test'`, id.FullyQualifiedName()) + assertOptsValidAndSQLEquals(t, opts, `ALTER APPLICATION PACKAGE IF EXISTS %s ADD PATCH FOR VERSION v1_1 USING '@hello_snowflake_code.core.hello_snowflake_stage' LABEL = 'test'`, id.FullyQualifiedName()) }) } diff --git a/pkg/sdk/application_packages_impl_gen.go b/pkg/sdk/application_packages_impl_gen.go index becae6598d..3add1188c7 100644 --- a/pkg/sdk/application_packages_impl_gen.go +++ b/pkg/sdk/application_packages_impl_gen.go @@ -65,12 +65,6 @@ func (r *AlterApplicationPackageRequest) toOpts() *AlterApplicationPackageOption IfExists: r.IfExists, name: r.name, - UnsetDataRetentionTimeInDays: r.UnsetDataRetentionTimeInDays, - UnsetMaxDataExtensionTimeInDays: r.UnsetMaxDataExtensionTimeInDays, - UnsetDefaultDdlCollation: r.UnsetDefaultDdlCollation, - UnsetComment: r.UnsetComment, - UnsetDistribution: r.UnsetDistribution, - SetTags: r.SetTags, UnsetTags: r.UnsetTags, } @@ -83,6 +77,15 @@ func (r *AlterApplicationPackageRequest) toOpts() *AlterApplicationPackageOption Distribution: r.Set.Distribution, } } + if r.Unset != nil { + opts.Unset = &ApplicationPackageUnset{ + DataRetentionTimeInDays: r.Unset.DataRetentionTimeInDays, + MaxDataExtensionTimeInDays: r.Unset.MaxDataExtensionTimeInDays, + DefaultDdlCollation: r.Unset.DefaultDdlCollation, + Comment: r.Unset.Comment, + Distribution: r.Unset.Distribution, + } + } if r.ModifyReleaseDirective != nil { opts.ModifyReleaseDirective = &ModifyReleaseDirective{ ReleaseDirective: r.ModifyReleaseDirective.ReleaseDirective, diff --git a/pkg/sdk/application_packages_validations_gen.go b/pkg/sdk/application_packages_validations_gen.go index e781aef63c..de5102bf76 100644 --- a/pkg/sdk/application_packages_validations_gen.go +++ b/pkg/sdk/application_packages_validations_gen.go @@ -26,8 +26,13 @@ func (opts *AlterApplicationPackageOptions) validate() error { if !ValidObjectIdentifier(opts.name) { errs = append(errs, ErrInvalidObjectIdentifier) } - if !exactlyOneValueSet(opts.Set, opts.UnsetDataRetentionTimeInDays, opts.UnsetMaxDataExtensionTimeInDays, opts.UnsetDefaultDdlCollation, opts.UnsetComment, opts.UnsetDistribution, opts.ModifyReleaseDirective, opts.SetDefaultReleaseDirective, opts.SetReleaseDirective, opts.UnsetReleaseDirective, opts.AddVersion, opts.DropVersion, opts.AddPatchForVersion, opts.SetTags, opts.UnsetTags) { - errs = append(errs, errExactlyOneOf("AlterApplicationPackageOptions", "Set", "UnsetDataRetentionTimeInDays", "UnsetMaxDataExtensionTimeInDays", "UnsetDefaultDdlCollation", "UnsetComment", "UnsetDistribution", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags")) + if !exactlyOneValueSet(opts.Set, opts.Unset, opts.ModifyReleaseDirective, opts.SetDefaultReleaseDirective, opts.SetReleaseDirective, opts.UnsetReleaseDirective, opts.AddVersion, opts.DropVersion, opts.AddPatchForVersion, opts.SetTags, opts.UnsetTags) { + errs = append(errs, errExactlyOneOf("AlterApplicationPackageOptions", "Set", "Unset", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags")) + } + if valueSet(opts.Unset) { + if !exactlyOneValueSet(opts.Unset.DataRetentionTimeInDays, opts.Unset.MaxDataExtensionTimeInDays, opts.Unset.DefaultDdlCollation, opts.Unset.Comment, opts.Unset.Distribution) { + errs = append(errs, errExactlyOneOf("AlterApplicationPackageOptions.Unset", "DataRetentionTimeInDays", "MaxDataExtensionTimeInDays", "DefaultDdlCollation", "Comment", "Distribution")) + } } return JoinErrors(errs...) } diff --git a/pkg/sdk/testint/application_packages_integration_test.go b/pkg/sdk/testint/application_packages_integration_test.go index 08d39dc297..7724b0e1c6 100644 --- a/pkg/sdk/testint/application_packages_integration_test.go +++ b/pkg/sdk/testint/application_packages_integration_test.go @@ -124,14 +124,16 @@ func TestInt_ApplicationPackages(t *testing.T) { id := sdk.NewAccountObjectIdentifier(e.Name) // unset comment - err := client.ApplicationPackages.Alter(ctx, sdk.NewAlterApplicationPackageRequest(id).WithUnsetComment(sdk.Bool(true))) + unset := sdk.NewApplicationPackageUnsetRequest().WithComment(sdk.Bool(true)) + err := client.ApplicationPackages.Alter(ctx, sdk.NewAlterApplicationPackageRequest(id).WithUnset(unset)) require.NoError(t, err) o, err := client.ApplicationPackages.ShowByID(ctx, id) require.NoError(t, err) require.Empty(t, o.Comment) // unset distribution - err = client.ApplicationPackages.Alter(ctx, sdk.NewAlterApplicationPackageRequest(id).WithUnsetDistribution(sdk.Bool(true))) + unset = sdk.NewApplicationPackageUnsetRequest().WithDistribution(sdk.Bool(true)) + err = client.ApplicationPackages.Alter(ctx, sdk.NewAlterApplicationPackageRequest(id).WithUnset(unset)) require.NoError(t, err) o, err = client.ApplicationPackages.ShowByID(ctx, id) require.NoError(t, err) @@ -232,12 +234,14 @@ func TestInt_ApplicationPackagesVersionAndReleaseDirective(t *testing.T) { return e } - uploadFileForStageHandle := func(t *testing.T, id sdk.SchemaObjectIdentifier, name string) { + putOnStageHandle := func(t *testing.T, id sdk.SchemaObjectIdentifier, name string) { t.Helper() - f, err := os.CreateTemp("", name) + + tempFile := fmt.Sprintf("/tmp/%s", name) + f, err := os.Create(tempFile) require.NoError(t, err) f.Close() - defer os.Remove(f.Name()) + defer os.Remove(name) _, err = client.ExecForTests(ctx, fmt.Sprintf(`PUT file://%s @%s AUTO_COMPRESS = FALSE OVERWRITE = TRUE`, f.Name(), id.FullyQualifiedName())) require.NoError(t, err) @@ -259,8 +263,8 @@ func TestInt_ApplicationPackagesVersionAndReleaseDirective(t *testing.T) { t.Run("alter application package: add, patch and drop version", func(t *testing.T) { e := createApplicationPackageHandle(t) s := createStageHandle(t) - uploadFileForStageHandle(t, s.ID(), "manifest.yml") - uploadFileForStageHandle(t, s.ID(), "setup.sql") + putOnStageHandle(t, s.ID(), "manifest.yml") + putOnStageHandle(t, s.ID(), "setup.sql") version := "V001" using := "@" + s.ID().FullyQualifiedName() @@ -298,8 +302,8 @@ func TestInt_ApplicationPackagesVersionAndReleaseDirective(t *testing.T) { t.Run("alter application package: set default release directive", func(t *testing.T) { e := createApplicationPackageHandle(t) s := createStageHandle(t) - uploadFileForStageHandle(t, s.ID(), "manifest.yml") - uploadFileForStageHandle(t, s.ID(), "setup.sql") + putOnStageHandle(t, s.ID(), "manifest.yml") + putOnStageHandle(t, s.ID(), "setup.sql") version := "V001" using := "@" + s.ID().FullyQualifiedName()