<commit_before>package libvirt

import (
	"fmt"
	"reflect"
	"testing"

	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"
	"github.com/libvirt/libvirt-go"
	"github.com/libvirt/libvirt-go-xml"
)

func getNetworkDef(s *terraform.State, name string) (*libvirtxml.Network, error) {
	var network *libvirt.Network
	rs, ok := s.RootModule().Resources[name]
	if !ok {
		return nil, fmt.Errorf("Not found: %s", name)
	}
	if rs.Primary.ID == "" {
		return nil, fmt.Errorf("No libvirt network ID is set")
	}
	virConn := testAccProvider.Meta().(*Client).libvirt
	network, err := virConn.LookupNetworkByUUIDString(rs.Primary.ID)
	if err != nil {
		return nil, err
	}
	networkDef, err := newDefNetworkfromLibvirt(network)
	if err != nil {
		return nil, fmt.Errorf("Error reading libvirt network XML description: %s", err)
	}
	return &networkDef, nil
}

func TestAccCheckLibvirtNetwork_LocalOnly(t *testing.T) {
	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckLibvirtNetworkDestroy,
		Steps: []resource.TestStep{
			{
				Config: fmt.Sprintf(`
				resource "libvirt_network" "test_net" {
					name      = "networktest"
					domain    = "k8s.local"
					addresses = ["10.17.3.0/24"]
					dns {
						local_only = true
					}
				}`),
				Check: resource.ComposeTestCheckFunc(
					resource.TestCheckResourceAttr("libvirt_network.test_net", "dns.0.local_only", "true"),
					checkLocalOnly("libvirt_network.test_net", true),
				),
			},
		},<commit_msg>fix function name changed.<commit_after>package libvirt

import (
	"fmt"
	"reflect"
	"testing"

	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"
	"github.com/libvirt/libvirt-go"
	"github.com/libvirt/libvirt-go-xml"
)

func getNetworkDef(s *terraform.State, name string) (*libvirtxml.Network, error) {
	var network *libvirt.Network
	rs, ok := s.RootModule().Resources[name]
	if !ok {
		return nil, fmt.Errorf("Not found: %s", name)
	}
	if rs.Primary.ID == "" {
		return nil, fmt.Errorf("No libvirt network ID is set")
	}
	virConn := testAccProvider.Meta().(*Client).libvirt
	network, err := virConn.LookupNetworkByUUIDString(rs.Primary.ID)
	if err != nil {
		return nil, err
	}
	networkDef, err := getXMLNetworkDefFromLibvirt(network)
	if err != nil {
		return nil, fmt.Errorf("Error reading libvirt network XML description: %s", err)
	}
	return &networkDef, nil
}

func TestAccCheckLibvirtNetwork_LocalOnly(t *testing.T) {
	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckLibvirtNetworkDestroy,
		Steps: []resource.TestStep{
			{
				Config: fmt.Sprintf(`
				resource "libvirt_network" "test_net" {
					name      = "networktest"
					domain    = "k8s.local"
					addresses = ["10.17.3.0/24"]
					dns {
						local_only = true
					}
				}`),
				Check: resource.ComposeTestCheckFunc(
					resource.TestCheckResourceAttr("libvirt_network.test_net", "dns.0.local_only", "true"),
					checkLocalOnly("libvirt_network.test_net", true),
				),
			},
		},
{'fraction_non_alphanumeric': 0.13902900378310215, 'fraction_numerical': 0.006305170239596469, 'mean_word_length': 3.9811616954474096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 2, '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': '3617320', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1122, 'n_words': 215}