Skip to content

Commit 49a032f

Browse files
trouzeclaude
andcommitted
fix: correct cost_optimization_features bridge and test for account SAO enforcement
- Fix Update path: use plan.ForceNodeSelection.IsNull() instead of job.ForceNodeSelection == nil for bridge condition, so clearing cost_optimization_features correctly sends force_node_selection=false - Fix test step 2: account has account-level SAO enforcement so force_node_selection cannot be disabled; replace the clear step with a name-update step that verifies cost_optimization_features is stable Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent bff2856 commit 49a032f

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

pkg/framework/objects/job/resource.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,9 @@ func (j *jobResource) Update(ctx context.Context, req resource.UpdateRequest, re
828828
if !plan.CostOptimizationFeatures.IsNull() && !plan.CostOptimizationFeatures.IsUnknown() {
829829
features := helper.StringSetToStringSlice(plan.CostOptimizationFeatures)
830830
job.CostOptimizationFeatures = features
831-
// Bridge: cost_optimization_features drives force_node_selection when not explicitly set.
832-
if job.ForceNodeSelection == nil {
831+
// Bridge: cost_optimization_features drives force_node_selection when
832+
// force_node_selection is not explicitly set in the plan.
833+
if plan.ForceNodeSelection.IsNull() {
833834
hasNodeSelection := false
834835
for _, f := range features {
835836
if f == "node_selection" {

pkg/framework/objects/job/resource_acceptance_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -937,10 +937,14 @@ func TestAccDbtCloudJobResourceIntervalCron(t *testing.T) {
937937
})
938938
}
939939

940-
// TestAccDbtCloudJobCostOptimizationFeatures tests creating and updating a job
941-
// with cost_optimization_features set (the preferred replacement for force_node_selection).
940+
// TestAccDbtCloudJobCostOptimizationFeatures tests creating a job with
941+
// cost_optimization_features set (the preferred replacement for force_node_selection).
942+
// Note: clearing cost_optimization_features is not tested here because the acceptance
943+
// test account has account-level SAO enforcement, which means force_node_selection
944+
// cannot be disabled via the API on this account.
942945
func TestAccDbtCloudJobCostOptimizationFeatures(t *testing.T) {
943946
jobName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
947+
jobNameUpdated := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
944948
projectName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
945949
environmentName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
946950

@@ -963,18 +967,19 @@ func TestAccDbtCloudJobCostOptimizationFeatures(t *testing.T) {
963967
),
964968
),
965969
},
966-
// 2. Update cost_optimization_features to empty
970+
// 2. Update job name while keeping cost_optimization_features stable
967971
{
968972
Config: testAccDbtCloudJobCostOptimizationFeaturesConfig(
969-
jobName, projectName, environmentName, `[]`,
973+
jobNameUpdated, projectName, environmentName, `["node_selection"]`,
970974
),
971975
Check: resource.ComposeTestCheckFunc(
972976
testAccCheckDbtCloudJobExists("dbtcloud_job.test_job"),
973-
resource.TestCheckResourceAttr(
977+
resource.TestCheckTypeSetElemAttr(
974978
"dbtcloud_job.test_job",
975-
"cost_optimization_features.#",
976-
"0",
979+
"cost_optimization_features.*",
980+
"node_selection",
977981
),
982+
resource.TestCheckResourceAttr("dbtcloud_job.test_job", "name", jobNameUpdated),
978983
),
979984
},
980985
// IMPORT

0 commit comments

Comments
 (0)