From 7c9ba61ae7cc24bafe1faaad14227c9dec3727da Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 5 Jul 2018 16:01:30 -0400 Subject: [PATCH] e2e/framework: strip flag prefix and use testify/require for embedded assertions --- e2e/framework/case.go | 20 ++++++++++---------- e2e/framework/framework.go | 30 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/e2e/framework/case.go b/e2e/framework/case.go index 77c0daa20..9587b28bf 100644 --- a/e2e/framework/case.go +++ b/e2e/framework/case.go @@ -61,11 +61,11 @@ func (c Constraints) matches(env Environment) error { // TC is the base test case which should be embedded in TestCase implementations. // It also embeds testify assertions configured with the current *testing.T // context. For more information on assertions: -// https://godoc.org/github.com/stretchr/testify/assert#Assertions +// https://godoc.org/github.com/stretchr/testify/require#Assertions type TC struct { - *assert.Assertions - require *require.Assertions - t *testing.T + *require.Assertions + assert *assert.Assertions + t *testing.T cluster *ClusterInfo prefix string @@ -97,14 +97,14 @@ func (tc *TC) T() *testing.T { // SetT sets the current *testing.T context func (tc *TC) SetT(t *testing.T) { tc.t = t - tc.Assertions = assert.New(t) - tc.require = require.New(t) + tc.Assertions = require.New(t) + tc.assert = assert.New(t) } -// Require fetches a require flavor of testify assertions -// https://godoc.org/github.com/stretchr/testify/require -func (tc *TC) Require() *require.Assertions { - return tc.require +// Require fetches an assert flavor of testify assertions +// https://godoc.org/github.com/stretchr/testify/assert +func (tc *TC) Assert() *assert.Assertions { + return tc.assert } func (tc *TC) setClusterInfo(info *ClusterInfo) { diff --git a/e2e/framework/framework.go b/e2e/framework/framework.go index 12dd10703..9972b64f3 100644 --- a/e2e/framework/framework.go +++ b/e2e/framework/framework.go @@ -8,14 +8,14 @@ import ( "testing" ) -var fEnv = flag.String("nomad.env", "", "name of the environment executing against") -var fProvider = flag.String("nomad.env.provider", "", "cloud provider for which environment is executing against") -var fOS = flag.String("nomad.env.os", "", "operating system for which the environment is executing against") -var fArch = flag.String("nomad.env.arch", "", "cpu architecture for which the environment is executing against") -var fTags = flag.String("nomad.env.tags", "", "comma delimited list of tags associated with the environment") -var fLocal = flag.Bool("nomad.local", false, "denotes execution is against a local environment") -var fSlow = flag.Bool("nomad.slow", false, "toggles execution of slow test suites") -var fForceAll = flag.Bool("nomad.force", false, "if set, skips all environment checks when filtering test suites") +var fEnv = flag.String("env", "", "name of the environment executing against") +var fProvider = flag.String("env.provider", "", "cloud provider for which environment is executing against") +var fOS = flag.String("env.os", "", "operating system for which the environment is executing against") +var fArch = flag.String("env.arch", "", "cpu architecture for which the environment is executing against") +var fTags = flag.String("env.tags", "", "comma delimited list of tags associated with the environment") +var fLocal = flag.Bool("local", false, "denotes execution is against a local environment") +var fSlow = flag.Bool("slow", false, "toggles execution of slow test suites") +var fForceRun = flag.Bool("forceRun", false, "if set, skips all environment checks when filtering test suites") var pkgFramework = New() @@ -33,11 +33,11 @@ type Framework struct { // framework is targeting. During 'go run', these fields are populated by // the following flags: // -// -nomad.env "name of the environment executing against" -// -nomad.env.provider "cloud provider for which the environment is executing against" -// -nomad.env.os "operating system of environment" -// -nomad.env.arch "cpu architecture of environment" -// -nomad.env.tags "comma delimited list of environment tags" +// -env "name of the environment executing against" +// -env.provider "cloud provider for which the environment is executing against" +// -env.os "operating system of environment" +// -env.arch "cpu architecture of environment" +// -env.tags "comma delimited list of environment tags" // // These flags are not needed when executing locally type Environment struct { @@ -65,7 +65,7 @@ func New() *Framework { env: env, isLocalRun: *fLocal, slow: *fSlow, - force: *fForceAll, + force: *fForceRun, } } @@ -109,7 +109,7 @@ func Run(t *testing.T) { // If skip is false and an error is returned, the test suite is failed. func (f *Framework) runSuite(t *testing.T, s *TestSuite) (skip bool, err error) { - // If -nomad.force is set, skip all constraint checks + // If -forceRun is set, skip all constraint checks if !f.force { // If this is a local run, check that the suite supports running locally if !s.CanRunLocal && f.isLocalRun {