/*
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
*/

package multitenant_test

import (
	"testing"

	network "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101"
	"github.com/Azure/azure-service-operator/v2/internal/testcommon"
)

func Test_Multitenant_ResourceCanBeCreated(t *testing.T) {
	t.Parallel()

	tc := globalTestContext.ForTest(t)

	// The tenant operator has been set up to watch only two
	// namespaces: t1-items and t1-more. Set the test context to
	// create items in the item's namespace.
	tc.Namespace = "t1-items"
	rg := tc.CreateTestResourceGroupAndWait()

	// Test creating another resource to ensure conversion webhooks
	// are working - resource group is the only one without multiple
	// versions (and so no conversion webhooks).
	vnet := network.VirtualNetwork{
		ObjectMeta: tc.MakeObjectMetaWithName(tc.Namer.GenerateName("vn")),
		Spec: network.VirtualNetwork_Spec{
			Owner:    testcommon.AsOwner(rg),
			Location: tc.AzureRegion,
			AddressSpace: &network.AddressSpace{
				AddressPrefixes: []string{"10.0.0.0/8"},
			},
		},
	}
	tc.CreateResourceAndWait(&vnet)

	tc.DeleteResourcesAndWait(&vnet, rg)
}
