From 5d1f5093ad08906a3e3c4a67a6374caf6bdbab01 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Mon, 2 Oct 2023 22:10:18 -0700 Subject: [PATCH] Fix linting issues --- xoa/acc_setup_test.go | 61 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/xoa/acc_setup_test.go b/xoa/acc_setup_test.go index faf90fb2..71dd4adc 100644 --- a/xoa/acc_setup_test.go +++ b/xoa/acc_setup_test.go @@ -27,38 +27,37 @@ func TestMain(m *testing.M) { // This leverages the existing flag defined in the terraform-plugin-sdk // repo defined below // https://github.com/hashicorp/terraform-plugin-sdk/blob/2c03a32a9d1be63a12eb18aaf12d2c5270c42346/helper/resource/testing.go#L58 - flag.Parse() - flagSweep := flag.Lookup("sweep") + flag.Parse() + flagSweep := flag.Lookup("sweep") if flagSweep != nil && flagSweep.Value.String() != "" { - _, runSetup := os.LookupEnv("TF_ACC") + _, runSetup := os.LookupEnv("TF_ACC") + + if runSetup { + fmt.Println("Running sweeping") + resource.TestMain(m) + + client.FindPoolForTests(&accTestPool) + client.FindPIFForTests(&accTestPIF) + client.FindTemplateForTests(&testTemplate, accTestPool.Id, "XOA_TEMPLATE") + client.FindTemplateForTests(&disklessTestTemplate, accTestPool.Id, "XOA_DISKLESS_TEMPLATE") + client.FindHostForTests(accTestPool.Master, &accTestHost) + client.FindNetworkForTests(accTestPool.Id, &accDefaultNetwork) + client.FindStorageRepositoryForTests(accTestPool, &accDefaultSr, accTestPrefix) + client.FindIsoStorageRepositoryForTests(accTestPool, &accIsoSr, accTestPrefix, "XOA_ISO_SR") + client.CreateUser(&accUser) + testIsoName = os.Getenv("XOA_ISO") + fmt.Printf("Found the following pool: %v sr: %v\n", accTestPool, accDefaultSr) + + code := m.Run() + client.RemoveNetworksWithNamePrefix(accTestPrefix)("") + client.RemoveVDIsWithPrefix(accTestPrefix)("") + client.RemoveResourceSetsWithNamePrefix(accTestPrefix)("") + client.RemoveTagFromAllObjects(accTestPrefix)("") + client.RemoveUsersWithPrefix(accTestPrefix)("") + client.RemoveCloudConfigsWithPrefix(accTestPrefix)("") + os.Exit(code) + } + } - if runSetup { - fmt.Println("Running sweeping") - resource.TestMain(m) - - client.FindPoolForTests(&accTestPool) - client.FindPIFForTests(&accTestPIF) - client.FindTemplateForTests(&testTemplate, accTestPool.Id, "XOA_TEMPLATE") - client.FindTemplateForTests(&disklessTestTemplate, accTestPool.Id, "XOA_DISKLESS_TEMPLATE") - client.FindHostForTests(accTestPool.Master, &accTestHost) - client.FindNetworkForTests(accTestPool.Id, &accDefaultNetwork) - client.FindStorageRepositoryForTests(accTestPool, &accDefaultSr, accTestPrefix) - client.FindIsoStorageRepositoryForTests(accTestPool, &accIsoSr, accTestPrefix, "XOA_ISO_SR") - client.CreateUser(&accUser) - testIsoName = os.Getenv("XOA_ISO") - fmt.Printf("Found the following pool: %v sr: %v\n", accTestPool, accDefaultSr) - - code := m.Run() - client.RemoveNetworksWithNamePrefix(accTestPrefix)("") - client.RemoveVDIsWithPrefix(accTestPrefix)("") - client.RemoveResourceSetsWithNamePrefix(accTestPrefix)("") - client.RemoveTagFromAllObjects(accTestPrefix)("") - client.RemoveUsersWithPrefix(accTestPrefix)("") - client.RemoveCloudConfigsWithPrefix(accTestPrefix)("") - os.Exit(code) - } - } - - }