MCPcopy Create free account
hub / github.com/coder/coder / TestProvision

Function TestProvision

provisioner/terraform/provision_test.go:391–1202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

389}
390
391func TestProvision(t *testing.T) {
392 t.Parallel()
393
394 testCases := []struct {
395 Name string
396 Files map[string]string
397 Metadata *proto.Metadata
398 Request *proto.PlanRequest
399 // Response may be nil to not check the response.
400 Response *proto.GraphComplete
401 InitResponse *proto.InitComplete
402 InitErrorContains string
403 InitExpectLogContains string
404 // If ErrorContains is not empty, PlanComplete should have an Error containing the given string
405 PlanErrorContains string
406 // If PlanExpectLogContains is not empty, then the logs should contain it.
407 PlanExpectLogContains string
408 // If Apply is true, then send an Apply request and check we get the same Resources as in Response.
409 Apply bool
410 // Some tests may need to be skipped until the relevant provider version is released.
411 SkipReason string
412 // If SkipCacheProviders is true, then skip caching the terraform providers for this test.
413 SkipCacheProviders bool
414 }{
415 {
416 Name: "missing-variable",
417 Files: map[string]string{
418 "main.tf": `variable "A" {
419 }`,
420 },
421 PlanErrorContains: "terraform plan:",
422 PlanExpectLogContains: "No value for required variable",
423 },
424 {
425 Name: "missing-variable-dry-run",
426 Files: map[string]string{
427 "main.tf": `variable "A" {
428 }`,
429 },
430 PlanErrorContains: "terraform plan:",
431 PlanExpectLogContains: "No value for required variable",
432 },
433 {
434 Name: "single-resource-dry-run",
435 Files: map[string]string{
436 "main.tf": `resource "null_resource" "A" {}`,
437 },
438 Response: &proto.GraphComplete{
439 Resources: []*proto.Resource{{
440 Name: "A",
441 Type: "null_resource",
442 }},
443 },
444 },
445 {
446 Name: "single-resource",
447 Files: map[string]string{
448 "main.tf": `resource "null_resource" "A" {}`,

Callers

nothing calls this directly

Calls 15

PersistentCacheDirFunction · 0.92
GetTestTFCacheDirFunction · 0.92
CacheTFProvidersFunction · 0.92
CreateTarFunction · 0.92
setupProvisionerFunction · 0.85
configureFunction · 0.85
sendInitAndGetRespFunction · 0.85
normalizeResourcesFunction · 0.85
RemoveAllMethod · 0.80
SkipMethod · 0.80
LogfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected