Skip to content

Commit d26774d

Browse files
committed
Add validation test to prevent regression of Update function requirement
1 parent e2fcaf5 commit d26774d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package github
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
)
8+
9+
func TestResourceGithubActionsSecretValidation(t *testing.T) {
10+
resource := resourceGithubActionsSecret()
11+
12+
// Verify the resource has an Update function
13+
if resource.Update == nil {
14+
t.Fatal("github_actions_secret resource must have an Update function to handle destroy_on_drift field changes")
15+
}
16+
17+
// Verify destroy_on_drift field exists and is configured correctly
18+
destroyOnDriftSchema, exists := resource.Schema["destroy_on_drift"]
19+
if !exists {
20+
t.Fatal("destroy_on_drift field should exist in schema")
21+
}
22+
23+
if destroyOnDriftSchema.Type != schema.TypeBool {
24+
t.Error("destroy_on_drift should be TypeBool")
25+
}
26+
27+
if !destroyOnDriftSchema.Optional {
28+
t.Error("destroy_on_drift should be Optional")
29+
}
30+
31+
if destroyOnDriftSchema.ForceNew {
32+
t.Error("destroy_on_drift should not be ForceNew when Update function exists")
33+
}
34+
}

0 commit comments

Comments
 (0)