Skip to content

Commit 3e4646d

Browse files
committed
test: Add validation tests for GitHub branch resource schema
1 parent ac3540b commit 3e4646d

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package github
2+
3+
import "testing"
4+
5+
func TestResourceGithubBranchAllowsUpdatesWhenBranchChanges(t *testing.T) {
6+
resource := resourceGithubBranch()
7+
8+
branchSchema := resource.Schema["branch"]
9+
if branchSchema == nil {
10+
t.Fatal("branch field should exist in schema")
11+
}
12+
if branchSchema.ForceNew {
13+
t.Error("branch field should not be ForceNew so renames are handled via update")
14+
}
15+
}
16+
17+
func TestResourceGithubBranchRecreatesWhenForceNewFieldsChange(t *testing.T) {
18+
resource := resourceGithubBranch()
19+
20+
forceNewFields := []string{"repository", "source_branch", "source_sha"}
21+
for _, name := range forceNewFields {
22+
field := resource.Schema[name]
23+
if field == nil {
24+
t.Fatalf("field %s should exist in schema", name)
25+
}
26+
if !field.ForceNew {
27+
t.Errorf("field %s should be ForceNew so changes recreate the resource", name)
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)