<commit_before>// Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

package main

import (
	"testing"
	"time"

	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"
	"github.com/oracle/bmcs-go-sdk"
	"github.com/stretchr/testify/suite"
)

type DatasourceIdentityPolicyTestSuite struct {
	suite.Suite
	Client       *baremetal.Client
	Provider     terraform.ResourceProvider
	Providers    map[string]terraform.ResourceProvider
	TimeCreated  time.Time
	Config       string
	ResourceName string
}

func (s *DatasourceIdentityPolicyTestSuite) SetupTest() {
	s.Client = testAccClient
	s.Provider = testAccProvider
	s.Providers = testAccProviders
	s.Config = testProviderConfig() + `
	resource "oci_identity_compartment" "t" {
		name = "-tf-compartment"
		description = "tf test compartment"
	}

	resource "oci_identity_group" "t" {
		name = "-tf-group"
		description = "automated test group"
	}

	resource "oci_identity_policy" "p" {
		name = "-tf-policy"
		description = "automated test policy"
		compartment_id = "${oci_identity_compartment.t.id}"
		statements = ["Allow group ${oci_identity_group.t.name} to read instances in compartment ${oci_identity_compartment.t.name}"]
	}`
	s.ResourceName = "data.oci_identity_policies.p"
}

func (s *DatasourceIdentityPolicyTestSuite) TestAccDatasourceIdentityPolicies_basic() {
	resource.Test(s.T(), resource.TestCase{
		Providers: s.Providers,
		Steps: []resource.TestStep{
			{
				ImportState:       true,
				ImportStateVerify: true,
				Config: s.Config + `	<commit_msg>address possible race condition in policy test<commit_after>// Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

package main

import (
	"testing"
	"time"

	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"
	"github.com/oracle/bmcs-go-sdk"
	"github.com/stretchr/testify/suite"
)

type DatasourceIdentityPolicyTestSuite struct {
	suite.Suite
	Client       *baremetal.Client
	Provider     terraform.ResourceProvider
	Providers    map[string]terraform.ResourceProvider
	TimeCreated  time.Time
	Config       string
	ResourceName string
}

func (s *DatasourceIdentityPolicyTestSuite) SetupTest() {
	s.Client = testAccClient
	s.Provider = testAccProvider
	s.Providers = testAccProviders
	s.Config = testProviderConfig() + `
	resource "oci_identity_compartment" "t" {
		name = "-tf-compartment"
		description = "tf test compartment"
	}

	resource "oci_identity_group" "t" {
		name = "-tf-group"
		description = "automated test group"
	}

	resource "oci_identity_policy" "p" {
		name = "-tf-policy"
		description = "automated test policy"
		compartment_id = "${oci_identity_compartment.t.id}"
		statements = ["Allow group ${oci_identity_group.t.name} to read instances in compartment ${oci_identity_compartment.t.name}"]
	}`
	s.ResourceName = "data.oci_identity_policies.p"
}

func (s *DatasourceIdentityPolicyTestSuite) TestAccDatasourceIdentityPolicies_basic() {
	resource.Test(s.T(), resource.TestCase{
		Providers: s.Providers,
		Steps: []resource.TestStep{
			{
				ImportState:       true,
				ImportStateVerify: true,
				Config: s.Config,
			},{
				Config: s.Config + `
{'fraction_non_alphanumeric': 0.11093798691181053, 'fraction_numerical': 0.0024929884699283265, 'mean_word_length': 4.506003430531733, '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': '241839', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1076, 'n_words': 218}