<commit_before>package azure

import (
	"fmt"
	"math/rand"
	"testing"
	"time"

	"github.com/Azure/azure-sdk-for-go/management"
	"github.com/Azure/azure-sdk-for-go/management/virtualmachine"
	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"
)

var randInt = rand.New(rand.NewSource(time.Now().UnixNano())).Int()
var instanceName = fmt.Sprintf("terraform-test-%d", randInt)

func TestAccAzureInstance_basic(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(""),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_basic,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", "", &dpmt),
					testAccCheckAzureInstanceBasicAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", instanceName),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", instanceName),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "location", "West US"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.2462817782.public_port", "22"),
				),
			},
		},
	})
}

func TestAccAzureInstance_separateHostedService(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(testAccHostedServiceName),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_separateHostedService,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", testAccHostedServiceName, &dpmt),
					testAccCheckAzureInstanceBasicAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", instanceName),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", "terraform-testing-service"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "location", "West US"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.2462817782.public_port", "22"),
				),
			},
		},
	})
}

func TestAccAzureInstance_advanced(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(""),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_advanced,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", "", &dpmt),
					testAccCheckAzureInstanceAdvancedAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "size", "Basic_A1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "subnet", "subnet1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "virtual_network", "terraform-vnet"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "security_group", "terraform-security-group1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.1814039778.public_port", "3389"),
				),
			},
		},
	})
}

func TestAccAzureInstance_update(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(""),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_advanced,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", "", &dpmt),
					testAccCheckAzureInstanceAdvancedAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "size", "Basic_A1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "subnet", "subnet1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "virtual_network", "terraform-vnet"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "security_group", "terraform-security-group1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.1814039778.public_port", "3389"),
				),
			},

			resource.TestStep{<commit_msg>provider/azure: Update vnet name in test checks<commit_after>package azure

import (
	"fmt"
	"math/rand"
	"testing"
	"time"

	"github.com/Azure/azure-sdk-for-go/management"
	"github.com/Azure/azure-sdk-for-go/management/virtualmachine"
	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"
)

var randInt = rand.New(rand.NewSource(time.Now().UnixNano())).Int()
var instanceName = fmt.Sprintf("terraform-test-%d", randInt)

func TestAccAzureInstance_basic(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(""),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_basic,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", "", &dpmt),
					testAccCheckAzureInstanceBasicAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", instanceName),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", instanceName),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "location", "West US"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.2462817782.public_port", "22"),
				),
			},
		},
	})
}

func TestAccAzureInstance_separateHostedService(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(testAccHostedServiceName),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_separateHostedService,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", testAccHostedServiceName, &dpmt),
					testAccCheckAzureInstanceBasicAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", instanceName),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", "terraform-testing-service"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "location", "West US"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.2462817782.public_port", "22"),
				),
			},
		},
	})
}

func TestAccAzureInstance_advanced(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(""),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_advanced,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", "", &dpmt),
					testAccCheckAzureInstanceAdvancedAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "size", "Basic_A1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "subnet", "subnet1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "virtual_network", "terraform-vnet-advanced-test"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "security_group", "terraform-security-group1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.1814039778.public_port", "3389"),
				),
			},
		},
	})
}

func TestAccAzureInstance_update(t *testing.T) {
	var dpmt virtualmachine.DeploymentResponse

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAzureInstanceDestroyed(""),
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccAzureInstance_advanced,
				Check: resource.ComposeTestCheckFunc(
					testAccCheckAzureInstanceExists(
						"azure_instance.foo", "", &dpmt),
					testAccCheckAzureInstanceAdvancedAttributes(&dpmt),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "hosted_service_name", "terraform-test1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "size", "Basic_A1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "subnet", "subnet1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "virtual_network", "terraform-vnet-advanced-test"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "security_group", "terraform-security-group1"),
					resource.TestCheckResourceAttr(
						"azure_instance.foo", "endpoint.1814039778.public_port", "3389"),
				),
			},

			resource.TestStep{
{'fraction_non_alphanumeric': 0.12447299739008232, 'fraction_numerical': 0.012447299739008232, 'mean_word_length': 4.772305909617613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4149780', 'n_tokens_mistral': 3791, 'n_tokens_neox': 3110, 'n_words': 433}