Skip to content

Commit

Permalink
Streamline testcontext private names
Browse files Browse the repository at this point in the history
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Oct 21, 2024
1 parent fb6069e commit 8c3a92b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions e2e/testcontext/testcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ type TestContext struct {
Deployer deployers.Deployer
}

var testContextMap = make(map[string]TestContext)
var contexts = make(map[string]TestContext)

// Based on name passed, Init the deployer and Workload and stash in a map[string]TestContext
func AddTestContext(name string, w workloads.Workload, d deployers.Deployer) {
testContextMap[name] = TestContext{w, d}
contexts[name] = TestContext{w, d}
}

func DeleteTestContext(name string) {
delete(testContextMap, name)
delete(contexts, name)
}

// Search name in map for a TestContext to return, if not found go backward
Expand All @@ -33,14 +33,14 @@ func DeleteTestContext(name string) {
// - Search for above name first (it will not be found as we create context at a point where we have a d+w)
// - Search for "TestSuites/Exhaustive/DaemonSet/Subscription" (should be found)
func GetTestContext(name string) (TestContext, error) {
testCtx, ok := testContextMap[name]
testCtx, ok := contexts[name]
if !ok {
i := strings.LastIndex(name, "/")
if i < 1 {
return TestContext{}, fmt.Errorf("not a valid name in TestContext: %v", name)
}

testCtx, ok = testContextMap[name[0:i]]
testCtx, ok = contexts[name[0:i]]
if !ok {
return TestContext{}, fmt.Errorf("can not find testContext with name: %v", name)
}
Expand Down

0 comments on commit 8c3a92b

Please sign in to comment.