|
1 | 1 | package github |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "strings" |
5 | 4 | "testing" |
6 | 5 |
|
7 | 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
@@ -72,60 +71,6 @@ func TestEtagDiffSuppressFunction(t *testing.T) { |
72 | 71 | } |
73 | 72 | } |
74 | 73 |
|
75 | | -// TestEtagComputedOnlyRejectsSuppress verifies that the SDK rejects |
76 | | -// DiffSuppressFunc on Computed-only fields, proving Optional is required. |
77 | | -func TestEtagComputedOnlyRejectsSuppress(t *testing.T) { |
78 | | - p := &schema.Provider{ |
79 | | - ResourcesMap: map[string]*schema.Resource{ |
80 | | - "test": { |
81 | | - Schema: map[string]*schema.Schema{ |
82 | | - "etag": { |
83 | | - Type: schema.TypeString, |
84 | | - Computed: true, |
85 | | - DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { |
86 | | - return true |
87 | | - }, |
88 | | - DiffSuppressOnRefresh: true, |
89 | | - }, |
90 | | - }, |
91 | | - }, |
92 | | - }, |
93 | | - } |
94 | | - err := p.InternalValidate() |
95 | | - if err == nil { |
96 | | - t.Fatal("expected SDK to reject DiffSuppressFunc on Computed-only field") |
97 | | - } |
98 | | - if !strings.Contains(err.Error(), "DiffSuppressFunc") { |
99 | | - t.Fatalf("unexpected error: %s", err) |
100 | | - } |
101 | | -} |
102 | | - |
103 | | -// TestEtagOptionalComputedAcceptsSuppress verifies that the SDK accepts |
104 | | -// DiffSuppressFunc on Optional+Computed fields. |
105 | | -func TestEtagOptionalComputedAcceptsSuppress(t *testing.T) { |
106 | | - p := &schema.Provider{ |
107 | | - ResourcesMap: map[string]*schema.Resource{ |
108 | | - "test": { |
109 | | - Schema: map[string]*schema.Schema{ |
110 | | - "etag": { |
111 | | - Type: schema.TypeString, |
112 | | - Optional: true, |
113 | | - Computed: true, |
114 | | - DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool { |
115 | | - return true |
116 | | - }, |
117 | | - DiffSuppressOnRefresh: true, |
118 | | - }, |
119 | | - }, |
120 | | - }, |
121 | | - }, |
122 | | - } |
123 | | - err := p.InternalValidate() |
124 | | - if err != nil { |
125 | | - t.Fatalf("Optional+Computed with DiffSuppressFunc should be valid, got: %s", err) |
126 | | - } |
127 | | -} |
128 | | - |
129 | 74 | // TestEtagSchemaConsistency ensure DiffSuppressFunc and DiffSuppressOnRefresh are consistently applied. |
130 | 75 | func TestEtagSchemaConsistency(t *testing.T) { |
131 | 76 | resourcesWithEtag := map[string]*schema.Resource{ |
|
0 commit comments