Proof of concept wrapper for suite.Suite (#2410)
## Description Proof of concept for how to wrap suite.Suite and insert our own logic for determining if a test should be skipped or not. Adds a new env var for running only integration tests May require future work to add unit tests with the same (non-default) labels as their integration tests ## Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No ## Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup ## Issue(s) * #2373 ## Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
2e128726c0
commit
31c9195a12
@ -22,12 +22,15 @@ import (
|
|||||||
// Disconnected Test Section
|
// Disconnected Test Section
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
type DisconnectedGraphConnectorSuite struct {
|
type DisconnectedGraphConnectorSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDisconnectedGraphSuite(t *testing.T) {
|
func TestDisconnectedGraphSuite(t *testing.T) {
|
||||||
tester.LogTimeOfTest(t)
|
s := &DisconnectedGraphConnectorSuite{
|
||||||
suite.Run(t, new(DisconnectedGraphConnectorSuite))
|
Suite: tester.NewUnitSuite(t),
|
||||||
|
}
|
||||||
|
|
||||||
|
suite.Run(t, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DisconnectedGraphConnectorSuite) TestBadConnection() {
|
func (suite *DisconnectedGraphConnectorSuite) TestBadConnection() {
|
||||||
@ -66,8 +69,15 @@ func (suite *DisconnectedGraphConnectorSuite) TestBadConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
gc, err := NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), test.acct(t), Users, fault.New(true))
|
t := suite.T()
|
||||||
|
|
||||||
|
gc, err := NewGraphConnector(
|
||||||
|
ctx,
|
||||||
|
graph.HTTPClient(graph.NoTimeout()),
|
||||||
|
test.acct(t),
|
||||||
|
Users,
|
||||||
|
fault.New(true))
|
||||||
assert.Nil(t, gc, test.name+" failed")
|
assert.Nil(t, gc, test.name+" failed")
|
||||||
assert.NotNil(t, err, test.name+" failed")
|
assert.NotNil(t, err, test.name+" failed")
|
||||||
})
|
})
|
||||||
@ -108,13 +118,16 @@ func (suite *DisconnectedGraphConnectorSuite) TestGraphConnector_Status() {
|
|||||||
go statusTestTask(&gc, 4, 1, 1)
|
go statusTestTask(&gc, 4, 1, 1)
|
||||||
|
|
||||||
gc.AwaitStatus()
|
gc.AwaitStatus()
|
||||||
suite.NotEmpty(gc.PrintableStatus())
|
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
assert.NotEmpty(t, gc.PrintableStatus())
|
||||||
// Expect 8 objects
|
// Expect 8 objects
|
||||||
suite.Equal(8, gc.Status().ObjectCount)
|
assert.Equal(t, 8, gc.Status().ObjectCount)
|
||||||
// Expect 2 success
|
// Expect 2 success
|
||||||
suite.Equal(2, gc.Status().Successful)
|
assert.Equal(t, 2, gc.Status().Successful)
|
||||||
// Expect 2 folders
|
// Expect 2 folders
|
||||||
suite.Equal(2, gc.Status().FolderCount)
|
assert.Equal(t, 2, gc.Status().FolderCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DisconnectedGraphConnectorSuite) TestVerifyBackupInputs() {
|
func (suite *DisconnectedGraphConnectorSuite) TestVerifyBackupInputs() {
|
||||||
|
|||||||
@ -52,7 +52,7 @@ func RunOnAny(t *testing.T, tests ...string) {
|
|||||||
|
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
t.Skipf(
|
t.Skipf(
|
||||||
"one or more env vars mus be flagged to run this test: %v",
|
"one or more env vars must be flagged to run this test: %v",
|
||||||
strings.Join(tests, ", "))
|
strings.Join(tests, ", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
src/internal/tester/suite.go
Normal file
42
src/internal/tester/suite.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package tester
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Suite interface {
|
||||||
|
suite.TestingSuite
|
||||||
|
Run(name string, subtest func()) bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUnitSuite(t *testing.T) *unitSuite {
|
||||||
|
return new(unitSuite)
|
||||||
|
}
|
||||||
|
|
||||||
|
type unitSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIntegrationSuite(
|
||||||
|
t *testing.T,
|
||||||
|
envSets [][]string,
|
||||||
|
includeGroups ...string,
|
||||||
|
) *integrationSuite {
|
||||||
|
RunOnAny(
|
||||||
|
t,
|
||||||
|
append(
|
||||||
|
[]string{CorsoCITests},
|
||||||
|
includeGroups...,
|
||||||
|
)...,
|
||||||
|
)
|
||||||
|
|
||||||
|
MustGetEnvSets(t, envSets...)
|
||||||
|
|
||||||
|
return new(integrationSuite)
|
||||||
|
}
|
||||||
|
|
||||||
|
type integrationSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user