Skip to content

Commit

Permalink
Add per-test logger to test.Context
Browse files Browse the repository at this point in the history
This will be used to log errors during the test flow, and once we pass
the context to all utility functions, they will be able to use the right
logger instead of passing log argument everywhere.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Nov 28, 2024
1 parent 8d94cd4 commit 5f4621f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e/exhaustive_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Exhaustive(t *testing.T) {

for _, deployer := range Deployers {
for _, workload := range Workloads {
ctx := test.NewContext(workload, deployer)
ctx := test.NewContext(workload, deployer, util.Ctx.Log)
t.Run(ctx.Name, func(t *testing.T) {
t.Parallel()
runTestFlow(t, ctx)
Expand Down
5 changes: 4 additions & 1 deletion e2e/test/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package test
import (
"testing"

"github.com/go-logr/logr"
"github.com/ramendr/ramen/e2e/deployers"
"github.com/ramendr/ramen/e2e/dractions"
"github.com/ramendr/ramen/e2e/workloads"
Expand All @@ -15,15 +16,17 @@ type Context struct {
Workload workloads.Workload
Deployer deployers.Deployer
Name string
Log logr.Logger
}

func NewContext(w workloads.Workload, d deployers.Deployer) Context {
func NewContext(w workloads.Workload, d deployers.Deployer, log logr.Logger) Context {
name := deployers.GetCombinedName(d, w)

return Context{
Workload: w,
Deployer: d,
Name: name,
Log: log.WithName(name),
}
}

Expand Down

0 comments on commit 5f4621f

Please sign in to comment.