Skip to content

Commit

Permalink
Merge pull request #1737 from justinsb/harmonize_samples_and_fixtures…
Browse files Browse the repository at this point in the history
…_step2

chore: refactor unified_test to split out scenario execution
  • Loading branch information
google-oss-prow[bot] committed May 24, 2024
2 parents c5343b4 + ce485f6 commit 4cfd5b6
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions tests/e2e/unified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testPause bool, can
t.Run(fixture.Name, func(t *testing.T) {
ctx := addTestTimeout(ctx, t, subtestTimeout)

uniqueID := testvariable.NewUniqueID()

loadFixture := func(project testgcp.GCPProject) (*unstructured.Unstructured, create.CreateDeleteTestOptions) {
loadFixture := func(project testgcp.GCPProject, uniqueID string) (*unstructured.Unstructured, create.CreateDeleteTestOptions) {
primaryResource := bytesToUnstructured(t, fixture.Create, uniqueID, project)

opt := create.CreateDeleteTestOptions{CleanupResources: true}
Expand All @@ -170,9 +168,26 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testPause bool, can
return primaryResource, opt
}

runScenario(ctx, t, testPause, fixture, loadFixture)
})
}
})

// Do a cleanup while we can still handle the error.
t.Logf("shutting down manager")
cancel()
}

func runScenario(ctx context.Context, t *testing.T, testPause bool, fixture resourcefixture.ResourceFixture, loadFixture func(project testgcp.GCPProject, uniqueID string) (*unstructured.Unstructured, create.CreateDeleteTestOptions)) {
// Extra indentation to avoid merge conflicts
{
{
{
uniqueID := testvariable.NewUniqueID()

// Quickly load the fixture with a dummy project, just to see if we should skip it
{
_, opt := loadFixture(testgcp.GCPProject{ProjectID: "test-skip", ProjectNumber: 123456789})
_, opt := loadFixture(testgcp.GCPProject{ProjectID: "test-skip", ProjectNumber: 123456789}, uniqueID)
create.MaybeSkip(t, fixture.Name, opt.Create)
if testPause && containsCCOrCCC(opt.Create) {
t.Skipf("test case %q contains ConfigConnector or ConfigConnectorContext object(s): "+
Expand Down Expand Up @@ -217,7 +232,7 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testPause bool, can
createPausedCC(ctx, t, h.GetClient())
}

primaryResource, opt := loadFixture(project)
primaryResource, opt := loadFixture(project, uniqueID)

exportResources := []*unstructured.Unstructured{primaryResource}

Expand Down Expand Up @@ -659,13 +674,9 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testPause bool, can
h.CompareGoldenFile(expectedPath, got, normalizers...)
}
}
})
}
}
})

// Do a cleanup while we can still handle the error.
t.Logf("shutting down manager")
cancel()
}
}

// assertNoRequest checks that no POSTs or GETs are made against the cloud provider (GCP). This
Expand Down

0 comments on commit 4cfd5b6

Please sign in to comment.