From ead0c8f0b1eed91b51531a2db3ae06252d892dad Mon Sep 17 00:00:00 2001 From: James Jackson Date: Tue, 22 Sep 2020 14:10:43 -0700 Subject: [PATCH] test: add unit tests for module to test when resource group is empty or invalid. --- modules/azure/actiongroup_test.go | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 modules/azure/actiongroup_test.go diff --git a/modules/azure/actiongroup_test.go b/modules/azure/actiongroup_test.go new file mode 100644 index 000000000..f4d805429 --- /dev/null +++ b/modules/azure/actiongroup_test.go @@ -0,0 +1,53 @@ +// +build azure + +// NOTE: We use build tags to differentiate azure testing because we currently do not have azure access setup for +// CircleCI. + +package azure + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +/* +The below tests are currently stubbed out, with the expectation that they will throw errors. +If/when methods to create and delete network resources are added, these tests can be extended. +*/ + +func TestGetActionGroupResourceEWithMissingResourceGroupName(t *testing.T) { + t.Parallel() + + ruleName := "Hello" + resGroupName := "" + subscriptionID := "" + + _, err := GetActionGroupResourceE(ruleName, resGroupName, subscriptionID) + + require.Error(t, err) +} + +func TestGetActionGroupResourceEWithInvalidResourceGroupName(t *testing.T) { + t.Parallel() + + ruleName := "" + resGroupName := "Hello" + subscriptionID := "" + + _, err := GetActionGroupResourceE(ruleName, resGroupName, subscriptionID) + + require.Error(t, err) +} + +func TestGetActionGroupClient(t *testing.T) { + t.Parallel() + + subscriptionID := "" + + client, err := getActionGroupClient(subscriptionID) + + require.NoError(t, err) + assert.NotEmpty(t, *client) +}