Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/runner/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
)

type TestInfo struct {
Id int
ScenarioId int
Metadata metav1.ObjectMeta
Id int
ScenarioId int
ScenarioName string
Metadata metav1.ObjectMeta
}

type StepInfo struct {
Expand Down
11 changes: 6 additions & 5 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (r *runner) run(ctx context.Context, m mainstart, nsOptions v1alpha2.Namesp
return
}
// setup context
tc, err := r.setupTestContext(ctx, testId, scenarioId, tc, test, bindings...)
tc, err := r.setupTestContext(ctx, testId, scenarioId, scenarioName, tc, test, bindings...)
if fail(t, err) {
return
}
Expand Down Expand Up @@ -516,11 +516,12 @@ func (r *runner) setupNamespace(ctx context.Context, nsOptions v1alpha2.Namespac
return tc, nil
}

func (r *runner) setupTestContext(ctx context.Context, testId int, scenarioId int, tc enginecontext.TestContext, test discovery.Test, bindings ...v1alpha1.Binding) (enginecontext.TestContext, error) {
func (r *runner) setupTestContext(ctx context.Context, testId int, scenarioId int, scenarioName string, tc enginecontext.TestContext, test discovery.Test, bindings ...v1alpha1.Binding) (enginecontext.TestContext, error) {
tc = tc.WithBinding("test", TestInfo{
Id: testId,
ScenarioId: scenarioId,
Metadata: test.Test.ObjectMeta,
Id: testId,
ScenarioId: scenarioId,
ScenarioName: scenarioName,
Metadata: test.Test.ObjectMeta,
})
tc, err := enginecontext.WithBindings(tc, bindings...)
if err != nil {
Expand Down
22 changes: 22 additions & 0 deletions pkg/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,28 @@ func Test_runner_run(t *testing.T) {
}
}

func Test_runner_setupTestContext(t *testing.T) {
r := &runner{clock: clock.RealClock{}}
tc := enginecontext.EmptyContext(clock.RealClock{})
test := discovery.Test{
Test: &model.Test{
ObjectMeta: metav1.ObjectMeta{Name: "my-test"},
},
}
got, err := r.setupTestContext(context.TODO(), 1, 2, "my-scenario", tc, test)
assert.NoError(t, err)
binding, err := got.Bindings().Get("$test")
assert.NoError(t, err)
val, err := binding.Value()
assert.NoError(t, err)
info, ok := val.(TestInfo)
assert.True(t, ok)
assert.Equal(t, 1, info.Id)
assert.Equal(t, 2, info.ScenarioId)
assert.Equal(t, "my-scenario", info.ScenarioName)
assert.Equal(t, "my-test", info.Metadata.Name)
}

func Test_runner_onFail(t *testing.T) {
{
r := &runner{
Expand Down
Loading