Skip to content

Commit 0eee153

Browse files
committed
test: add backward compatibility test for cors_behavior on Coder 2.25
Adds TestAccTemplateResourceBackCompat that spins up Coder v2.25.0 (which does not support cors_behavior), creates a template without setting cors_behavior, and verifies the attribute is absent in state.
1 parent 8b0a77f commit 0eee153

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

internal/provider/template_resource_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,50 @@ func TestAccTemplateResourceEnterprise(t *testing.T) {
820820
})
821821
}
822822

823+
func TestAccTemplateResourceBackCompat(t *testing.T) {
824+
t.Parallel()
825+
if os.Getenv("TF_ACC") == "" {
826+
t.Skip("Acceptance tests are disabled.")
827+
}
828+
ctx := t.Context()
829+
// Coder 2.25 does not support cors_behavior. Verify that not setting it works.
830+
client := integration.StartCoder(ctx, t, "tmpl_back_compat_acc", integration.CoderVersion("v2.25.0"))
831+
832+
exTemplateOne := t.TempDir()
833+
err := cp.Copy("../../integration/template-test/example-template", exTemplateOne)
834+
require.NoError(t, err)
835+
836+
cfg1 := testAccTemplateResourceConfig{
837+
URL: client.URL.String(),
838+
Token: client.SessionToken(),
839+
Name: ptr.Ref("example-template"),
840+
Versions: []testAccTemplateVersionConfig{
841+
{
842+
Directory: &exTemplateOne,
843+
Active: ptr.Ref(true),
844+
},
845+
},
846+
ACL: testAccTemplateACLConfig{
847+
null: true,
848+
},
849+
}
850+
851+
resource.Test(t, resource.TestCase{
852+
PreCheck: func() { testAccPreCheck(t) },
853+
IsUnitTest: true,
854+
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
855+
Steps: []resource.TestStep{
856+
{
857+
Config: cfg1.String(t),
858+
Check: resource.ComposeTestCheckFunc(
859+
resource.TestCheckResourceAttrSet("coderd_template.test", "id"),
860+
resource.TestCheckNoResourceAttr("coderd_template.test", "cors_behavior"),
861+
),
862+
},
863+
},
864+
})
865+
}
866+
823867
func TestAccTemplateResourceAGPL(t *testing.T) {
824868
t.Parallel()
825869
if os.Getenv("TF_ACC") == "" {

0 commit comments

Comments
 (0)