-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[e2e] Abstract usage of ginkgo with a new test context (#3254)
- Loading branch information
Showing
20 changed files
with
611 additions
and
472 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package tests | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/ava-labs/avalanchego/wallet/subnet/primary/common" | ||
) | ||
|
||
// A long default timeout used to timeout failed operations but unlikely to induce | ||
// flaking due to unexpected resource contention. | ||
const DefaultTimeout = 2 * time.Minute | ||
|
||
// Helper simplifying use of a timed context by canceling the context with the test context. | ||
func ContextWithTimeout(tc TestContext, duration time.Duration) context.Context { | ||
ctx, cancel := context.WithTimeout(context.Background(), duration) | ||
tc.DeferCleanup(cancel) | ||
return ctx | ||
} | ||
|
||
// Helper simplifying use of a timed context configured with the default timeout. | ||
func DefaultContext(tc TestContext) context.Context { | ||
return ContextWithTimeout(tc, DefaultTimeout) | ||
} | ||
|
||
// Helper simplifying use via an option of a timed context configured with the default timeout. | ||
func WithDefaultContext(tc TestContext) common.Option { | ||
return common.WithContext(DefaultContext(tc)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.