コード例 #1
0
func TestAccArchiveFile_Basic(t *testing.T) {
	var fileSize string
	r.Test(t, r.TestCase{
		Providers: testProviders,
		Steps: []r.TestStep{
			r.TestStep{
				Config: testAccArchiveFileContentConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("data.archive_file.foo", "output_size", &fileSize),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileFileConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("data.archive_file.foo", "output_size", &fileSize),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileDirConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("data.archive_file.foo", "output_size", &fileSize),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileOutputPath,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists(fmt.Sprintf("%s/test.zip", tmpDir), &fileSize),
				),
			},
		},
	})
}
コード例 #2
0
func TestAccArchiveFile_Basic(t *testing.T) {
	var fileSize string
	r.Test(t, r.TestCase{
		Providers: testProviders,
		CheckDestroy: r.ComposeTestCheckFunc(
			testAccArchiveFileMissing("zip_file_acc_test.zip"),
		),
		Steps: []r.TestStep{
			r.TestStep{
				Config: testAccArchiveFileContentConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("archive_file.foo", "output_size", &fileSize),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileFileConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("archive_file.foo", "output_size", &fileSize),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileDirConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("archive_file.foo", "output_size", &fileSize),
				),
			},
		},
	})
}
コード例 #3
0
func TestAccArchiveFile_Basic(t *testing.T) {
	var fileSize string
	r.Test(t, r.TestCase{
		Providers: testProviders,
		Steps: []r.TestStep{
			r.TestStep{
				Config: testAccArchiveFileContentConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("data.archive_file.foo", "output_size", &fileSize),

					// We just check the hashes for syntax rather than exact
					// content since we don't want to break if the archive
					// library starts generating different bytes that are
					// functionally equivalent.
					r.TestMatchResourceAttr(
						"data.archive_file.foo", "output_base64sha256",
						regexp.MustCompile(`^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$`),
					),
					r.TestMatchResourceAttr(
						"data.archive_file.foo", "output_md5", regexp.MustCompile(`^[0-9a-f]{32}$`),
					),
					r.TestMatchResourceAttr(
						"data.archive_file.foo", "output_sha", regexp.MustCompile(`^[0-9a-f]{40}$`),
					),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileFileConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("data.archive_file.foo", "output_size", &fileSize),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileDirConfig,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
					r.TestCheckResourceAttrPtr("data.archive_file.foo", "output_size", &fileSize),
				),
			},
			r.TestStep{
				Config: testAccArchiveFileOutputPath,
				Check: r.ComposeTestCheckFunc(
					testAccArchiveFileExists(fmt.Sprintf("%s/test.zip", tmpDir), &fileSize),
				),
			},
		},
	})
}
コード例 #4
0
func TestAccAzureSqlDatabaseServiceAdvanced(t *testing.T) {
	name := "azure_sql_database_service.foo"

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureSqlDatabaseServiceDeleted,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureSqlDatabaseServiceConfigAdvanced,
				Check: resource.ComposeTestCheckFunc(
					testAccAzureSqlDatabaseServerGetName,
					testAccCheckAzureSqlDatabaseServiceExists(name),
					resource.TestCheckResourceAttr(name, "name", "terraform-testing-db"),
					resource.TestCheckResourceAttrPtr(name, "database_server_name",
						testAccAzureSqlServerName),
					resource.TestCheckResourceAttr(name, "edition", "Premium"),
					resource.TestCheckResourceAttr(name, "collation",
						"Arabic_BIN"),
					resource.TestCheckResourceAttr(name, "max_size_bytes", "10737418240"),
					resource.TestCheckResourceAttr(name, "service_level_id",
						"7203483a-c4fb-4304-9e9f-17c71c904f5d"),
				),
			},
		},
	})
}
func TestAccBrightboxFirewallRule_Basic(t *testing.T) {
	var firewall_rule brightbox.FirewallRule
	var firewall_policy brightbox.FirewallPolicy

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckBrightboxFirewallRuleAndPolicyDestroy,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccCheckBrightboxFirewallRuleConfig_basic,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBrightboxFirewallRuleExists("brightbox_firewall_rule.rule1", &firewall_rule),
					testAccCheckBrightboxFirewallPolicyExists("brightbox_firewall_policy.terraform", &firewall_policy),
					testAccCheckBrightboxEmptyFirewallRuleAttributes(&firewall_rule),
					resource.TestCheckResourceAttr(
						"brightbox_firewall_rule.rule1", "description", "outbound_rule"),
					resource.TestCheckResourceAttrPtr(
						"brightbox_firewall_rule.rule1", "firewall_policy", &firewall_policy.Id),
				),
			},
			resource.TestStep{
				Config: testAccCheckBrightboxFirewallRuleConfig_updated,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBrightboxFirewallRuleExists("brightbox_firewall_rule.rule1", &firewall_rule),
					resource.TestCheckResourceAttr(
						"brightbox_firewall_rule.rule1", "description", "updated"),
				),
			},
		},
	})
}
コード例 #6
0
func TestAccAzureSqlDatabaseServiceUpdate(t *testing.T) {
	name := "azure_sql_database_service.foo"

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureSqlDatabaseServiceDeleted,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureSqlDatabaseServiceConfigAdvanced,
				Check: resource.ComposeTestCheckFunc(
					testAccAzureSqlDatabaseServerGetName,
					testAccCheckAzureSqlDatabaseServiceExists(name),
					resource.TestCheckResourceAttr(name, "name", "terraform-testing-db"),
					resource.TestCheckResourceAttrPtr(name, "database_server_name",
						testAccAzureSqlServerName),
					resource.TestCheckResourceAttr(name, "edition", "Premium"),
					resource.TestCheckResourceAttr(name, "collation",
						"Arabic_BIN"),
					resource.TestCheckResourceAttr(name, "max_size_bytes", "10737418240"),
					resource.TestCheckResourceAttr(name, "service_level_id",
						"7203483a-c4fb-4304-9e9f-17c71c904f5d"),
				),
			},
			resource.TestStep{
				Config: testAccAzureSqlDatabaseServiceConfigUpdate,
				Check: resource.ComposeTestCheckFunc(
					testAccAzureSqlDatabaseServerGetName,
					testAccCheckAzureSqlDatabaseServiceExists(name),
					resource.TestCheckResourceAttr(name, "name",
						"terraform-testing-db-renamed"),
					resource.TestCheckResourceAttrPtr(name, "database_server_name",
						testAccAzureSqlServerName),
					resource.TestCheckResourceAttr(name, "edition", "Standard"),
					resource.TestCheckResourceAttr(name, "collation",
						"SQL_Latin1_General_CP1_CI_AS"),
					resource.TestCheckResourceAttr(name, "max_size_bytes", "5368709120"),
					resource.TestCheckResourceAttr(name, "service_level_id",
						"f1173c43-91bd-4aaa-973c-54e79e15235b"),
				),
			},
		},
	})
}
func TestAccBrightboxFirewallPolicy_mappings(t *testing.T) {
	var firewall_policy brightbox.FirewallPolicy
	var server_group brightbox.ServerGroup

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckBrightboxFirewallPolicyAndGroupDestroy,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccCheckBrightboxFirewallPolicyConfig_mapped,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBrightboxFirewallPolicyExists("brightbox_firewall_policy.foobar", &firewall_policy),
					testAccCheckBrightboxServerGroupExists("brightbox_server_group.group1", &server_group),
					resource.TestCheckResourceAttrPtr(
						"brightbox_firewall_policy.foobar", "server_group", &server_group.Id),
				),
			},
			resource.TestStep{
				Config: testAccCheckBrightboxFirewallPolicyConfig_remap,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBrightboxFirewallPolicyExists("brightbox_firewall_policy.foobar", &firewall_policy),
					testAccCheckBrightboxServerGroupExists("brightbox_server_group.group2", &server_group),
					resource.TestCheckResourceAttrPtr(
						"brightbox_firewall_policy.foobar", "server_group", &server_group.Id),
				),
			},
			resource.TestStep{
				Config: testAccCheckBrightboxFirewallPolicyConfig_unmap,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBrightboxFirewallPolicyExists("brightbox_firewall_policy.foobar", &firewall_policy),
					resource.TestCheckResourceAttr(
						"brightbox_firewall_policy.foobar", "server_group", ""),
				),
			},
		},
	})
}
func TestAccBrightboxContainer_Basic(t *testing.T) {
	var api_client brightbox.ApiClient

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckBrightboxContainerDestroy,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccCheckBrightboxContainerConfig_basic,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBrightboxContainerExists("brightbox_container.foobar", &api_client),
					testAccCheckBrightboxApiClientAttributes(&api_client),
					resource.TestCheckResourceAttr(
						"brightbox_container.foobar", "name", "initial"),
					resource.TestCheckResourceAttr(
						"brightbox_container.foobar", "description", "initial"),
					resource.TestCheckResourceAttrPtr(
						"brightbox_container.foobar", "auth_user", &api_client.Id),
					resource.TestCheckResourceAttrPtr(
						"brightbox_container.foobar", "account_id", &api_client.Account.Id),
				),
			},
			resource.TestStep{
				Config: testAccCheckBrightboxContainerConfig_updated,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBrightboxContainerExists("brightbox_container.foobar", &api_client),
					resource.TestCheckResourceAttr(
						"brightbox_container.foobar", "name", "updated"),
					resource.TestCheckResourceAttr(
						"brightbox_container.foobar", "description", "updated"),
				),
			},
		},
	})
}
func TestAccAzureSqlDatabaseServer(t *testing.T) {
	name := "azure_sql_database_server.foo"
	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureSqlDatabaseServerDeleted,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureSqlDatabaseServerConfig,
				Check: resource.ComposeTestCheckFunc(
					testAccAzureSqlDatabaseServerGetName,
					testAccCheckAzureSqlDatabaseServerExists(name),
					resource.TestCheckResourceAttrPtr(name, "name", testAccAzureSqlServerName),
					resource.TestCheckResourceAttr(name, "username", "SuperUser"),
					resource.TestCheckResourceAttr(name, "password", "SuperSEKR3T"),
					resource.TestCheckResourceAttr(name, "version", "2.0"),
				),
			},
		},
	})
}
コード例 #10
0
func TestAccAzureSqlDatabaseServiceBasic(t *testing.T) {
	name := "azure_sql_database_service.foo"

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureSqlDatabaseServiceDeleted,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureSqlDatabaseServiceConfigBasic,
				Check: resource.ComposeTestCheckFunc(
					testAccAzureSqlDatabaseServerGetName,
					testAccCheckAzureSqlDatabaseServiceExists(name),
					resource.TestCheckResourceAttr(name, "name", "terraform-testing-db"),
					resource.TestCheckResourceAttrPtr(name, "database_server_name",
						testAccAzureSqlServerName),
					resource.TestCheckResourceAttr(name, "collation",
						"SQL_Latin1_General_CP1_CI_AS"),
					resource.TestCheckResourceAttr(name, "edition", "Standard"),
				),
			},
		},
	})
}