corso/src/internal/tester/envvars_test.go
ashmrtn 09cc2769d9
Fix most remaining wsl lint errors (#656)
* Fix wsl lint errors in pkg package

* Fix wsl lint errors in most of internal package

Leave some sub-packages out that have higher churn at the moment.
2022-08-26 17:58:58 +00:00

48 lines
860 B
Go

package tester
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() {
envVariable := "TEST_ENVVARS_SUITE"
os.Setenv(envVariable, "1")
table := []struct {
name string
param string
function assert.ErrorAssertionFunc
}{
{
name: "Valid Environment",
param: envVariable,
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(envVariable)
}