|
| 1 | +package tnresources |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "encoding/json" |
| 6 | + "testing" |
| 7 | + |
| 8 | + "github.com/databricks/databricks-sdk-go/service/catalog" |
| 9 | + "github.com/stretchr/testify/assert" |
| 10 | + "github.com/stretchr/testify/require" |
| 11 | +) |
| 12 | + |
| 13 | +func TestResourceSchema_DoUpdate_WithUnsupportedForceSendFields(t *testing.T) { |
| 14 | + _, client := setupTestServerClient(t) |
| 15 | + |
| 16 | + adapter := (*ResourceSchema)(nil).New(client) |
| 17 | + ctx := context.Background() |
| 18 | + |
| 19 | + config := &catalog.CreateSchema{ |
| 20 | + CatalogName: "main", |
| 21 | + Name: "test_schema", |
| 22 | + Comment: "original comment", |
| 23 | + Properties: map[string]string{"key": "value"}, |
| 24 | + StorageRoot: "", |
| 25 | + ForceSendFields: nil, |
| 26 | + } |
| 27 | + |
| 28 | + id, _, err := adapter.DoCreate(ctx, config) |
| 29 | + require.NoError(t, err) |
| 30 | + |
| 31 | + config.Comment = "updated comment" |
| 32 | + config.Properties = map[string]string{"key": "updated_value"} |
| 33 | + config.ForceSendFields = []string{ |
| 34 | + "Comment", |
| 35 | + "Properties", |
| 36 | + "EnablePredictiveOptimization", // Unsupported - should be filtered out |
| 37 | + "NewName", // Unsupported - should be filtered out |
| 38 | + "Owner", // Unsupported - should be filtered out |
| 39 | + } |
| 40 | + |
| 41 | + _, err = adapter.DoUpdate(ctx, id, config) |
| 42 | + require.NoError(t, err) |
| 43 | + |
| 44 | + result, err := adapter.DoRefresh(ctx, id) |
| 45 | + require.NoError(t, err) |
| 46 | + |
| 47 | + resultJSON, err := json.Marshal(result) |
| 48 | + require.NoError(t, err) |
| 49 | + expected := `{ |
| 50 | + "catalog_name": "main", |
| 51 | + "comment": "updated comment", |
| 52 | + "properties": {"key": "updated_value"}, |
| 53 | + "full_name": "main.test_schema", |
| 54 | + "name": "test_schema" |
| 55 | + }` |
| 56 | + assert.JSONEq(t, expected, string(resultJSON)) |
| 57 | +} |
0 commit comments