From f713047f95497e70f45b0582a6c58924219381f6 Mon Sep 17 00:00:00 2001 From: Danny Date: Fri, 10 Jun 2022 10:41:45 -0400 Subject: [PATCH] Testing expansion (#177) Incremental tests added to project Functional test added to test package to showcase usage and streamline on GraphConnector test suite. --- src/internal/testing/envvars_test.go | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/internal/testing/envvars_test.go diff --git a/src/internal/testing/envvars_test.go b/src/internal/testing/envvars_test.go new file mode 100644 index 000000000..1e48774a5 --- /dev/null +++ b/src/internal/testing/envvars_test.go @@ -0,0 +1,45 @@ +package testing + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +type EnvvarsTestSuite struct { + suite.Suite +} + +func TestEnvvarsSuite(t *testing.T) { + suite.Run(t, new(EnvvarsTestSuite)) +} + +func (suite EnvvarsTestSuite) TestRunOnAny() { + env_variable := "TEST_ENVVARS_SUITE" + os.Setenv(env_variable, "1") + table := []struct { + name string + param string + function assert.ErrorAssertionFunc + }{ + { + name: "Valid Environment", + param: env_variable, + function: assert.NoError, + }, + { + name: "Invalid Environment", + param: "TEST_ENVVARS_SUITE_INVALID", + function: assert.Error, + }, + } + for _, test := range table { + suite.T().Run(test.name, func(t *testing.T) { + result := RunOnAny(test.param) + test.function(suite.T(), result) + }) + } + os.Unsetenv(env_variable) +}