|
4 | 4 | "context"
|
5 | 5 | "fmt"
|
6 | 6 | "regexp"
|
| 7 | + "strings" |
7 | 8 | "testing"
|
8 | 9 |
|
9 | 10 | "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
|
@@ -103,6 +104,78 @@ func TestAcc_Project(t *testing.T) {
|
103 | 104 | })
|
104 | 105 | }
|
105 | 106 |
|
| 107 | +func TestAcc_ProjectFluidCompute(t *testing.T) { |
| 108 | + projectSuffix := acctest.RandString(16) |
| 109 | + |
| 110 | + resource.Test(t, resource.TestCase{ |
| 111 | + PreCheck: func() { testAccPreCheck(t) }, |
| 112 | + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, |
| 113 | + CheckDestroy: testAccProjectDestroy("vercel_project.test", testTeam()), |
| 114 | + Steps: []resource.TestStep{ |
| 115 | + { |
| 116 | + // check we get a sensible error if fluid + invalid CPU combination. |
| 117 | + Config: ` |
| 118 | + resource "vercel_project" "test" { |
| 119 | + name = "foo" |
| 120 | + resource_config = { |
| 121 | + fluid = true |
| 122 | + function_default_cpu_type = "standard_legacy" |
| 123 | + } |
| 124 | + } |
| 125 | + `, |
| 126 | + ExpectError: regexp.MustCompile(strings.ReplaceAll("Fluid compute is only supported with the standard or performance CPU types.", " ", `\s*`)), |
| 127 | + }, |
| 128 | + { |
| 129 | + // check creating a project with Fluid |
| 130 | + Config: fmt.Sprintf(` |
| 131 | + resource "vercel_project" "test" { |
| 132 | + name = "test-acc-fluid-%[1]s" |
| 133 | + %[2]s |
| 134 | +
|
| 135 | + resource_config = { |
| 136 | + fluid = true |
| 137 | + } |
| 138 | + } |
| 139 | + `, projectSuffix, teamIDConfig()), |
| 140 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 141 | + resource.TestCheckResourceAttr("vercel_project.test", "name", fmt.Sprintf("test-acc-fluid-%s", projectSuffix)), |
| 142 | + resource.TestCheckResourceAttr("vercel_project.test", "resource_config.fluid", "true"), |
| 143 | + ), |
| 144 | + }, |
| 145 | + { |
| 146 | + // check updating Fluid on a project |
| 147 | + Config: fmt.Sprintf(` |
| 148 | + resource "vercel_project" "test" { |
| 149 | + name = "test-acc-fluid-%[1]s" |
| 150 | + %[2]s |
| 151 | +
|
| 152 | + resource_config = { |
| 153 | + fluid = false |
| 154 | + } |
| 155 | + } |
| 156 | + `, projectSuffix, teamIDConfig()), |
| 157 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 158 | + resource.TestCheckResourceAttr("vercel_project.test", "name", fmt.Sprintf("test-acc-fluid-%s", projectSuffix)), |
| 159 | + resource.TestCheckResourceAttr("vercel_project.test", "resource_config.fluid", "false"), |
| 160 | + ), |
| 161 | + }, |
| 162 | + { |
| 163 | + // check new projects without fluid specified shows fluid as false |
| 164 | + Config: fmt.Sprintf(` |
| 165 | + resource "vercel_project" "test" { |
| 166 | + name = "test-acc-fluid-disabled-%[1]s" |
| 167 | + %[2]s |
| 168 | + } |
| 169 | + `, projectSuffix, teamIDConfig()), |
| 170 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 171 | + resource.TestCheckResourceAttr("vercel_project.test", "name", fmt.Sprintf("test-acc-fluid-disabled-%s", projectSuffix)), |
| 172 | + resource.TestCheckResourceAttr("vercel_project.test", "resource_config.fluid", "false"), |
| 173 | + ), |
| 174 | + }, |
| 175 | + }, |
| 176 | + }) |
| 177 | +} |
| 178 | + |
106 | 179 | func TestAcc_ProjectAddingEnvAfterInitialCreation(t *testing.T) {
|
107 | 180 | projectSuffix := acctest.RandString(16)
|
108 | 181 | resource.Test(t, resource.TestCase{
|
|
0 commit comments