@@ -8,27 +8,39 @@ import (
88
99func TestResourceGithubActionsSecretValidation (t * testing.T ) {
1010 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 " )
11+
12+ // Verify the resource does NOT have an Update function since all fields are ForceNew
13+ if resource .Update ! = nil {
14+ t .Fatal ("github_actions_secret resource should not have an Update function when all fields are ForceNew " )
1515 }
16-
16+
1717 // Verify destroy_on_drift field exists and is configured correctly
1818 destroyOnDriftSchema , exists := resource .Schema ["destroy_on_drift" ]
1919 if ! exists {
2020 t .Fatal ("destroy_on_drift field should exist in schema" )
2121 }
22-
22+
2323 if destroyOnDriftSchema .Type != schema .TypeBool {
2424 t .Error ("destroy_on_drift should be TypeBool" )
2525 }
26-
26+
2727 if ! destroyOnDriftSchema .Optional {
2828 t .Error ("destroy_on_drift should be Optional" )
2929 }
30-
31- if destroyOnDriftSchema .ForceNew {
32- t .Error ("destroy_on_drift should not be ForceNew when Update function exists" )
30+
31+ if ! destroyOnDriftSchema .ForceNew {
32+ t .Error ("destroy_on_drift should be ForceNew when no Update function exists" )
33+ }
34+
35+ // Verify all user-configurable fields are ForceNew (which is why Update is unnecessary)
36+ expectedForceNewFields := []string {"repository" , "secret_name" , "encrypted_value" , "plaintext_value" , "destroy_on_drift" }
37+ for _ , fieldName := range expectedForceNewFields {
38+ field , exists := resource .Schema [fieldName ]
39+ if ! exists {
40+ continue // Skip fields that don't exist
41+ }
42+ if ! field .Computed && (field .Required || field .Optional ) && ! field .ForceNew {
43+ t .Errorf ("Field %s should have ForceNew: true since no Update function exists" , fieldName )
44+ }
3345 }
34- }
46+ }
0 commit comments