Skip to content

Commit

Permalink
Merge a88a461 into 125b455
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed May 22, 2024
2 parents 125b455 + a88a461 commit 986a857
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 64 deletions.
28 changes: 14 additions & 14 deletions bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ func TestBindRunnerRun(t *testing.T) {
map[string]any{},
store{
steps: []map[string]any{
{"run": true},
{},
},
vars: map[string]any{},
bindVars: map[string]any{},
},
map[string]any{
"steps": []map[string]any{
{"run": true},
{},
},
"vars": map[string]any{},
"parent": nil,
Expand All @@ -52,7 +52,7 @@ func TestBindRunnerRun(t *testing.T) {
},
store{
steps: []map[string]any{
{"run": true},
{},
},
vars: map[string]any{
"key": "value",
Expand All @@ -63,7 +63,7 @@ func TestBindRunnerRun(t *testing.T) {
},
map[string]any{
"steps": []map[string]any{
{"run": true},
{},
},
"vars": map[string]any{
"key": "value",
Expand All @@ -86,7 +86,7 @@ func TestBindRunnerRun(t *testing.T) {
},
store{
steps: []map[string]any{
{"run": true},
{},
},
vars: map[string]any{
"key": "value",
Expand All @@ -97,7 +97,7 @@ func TestBindRunnerRun(t *testing.T) {
},
map[string]any{
"steps": []map[string]any{
{"run": true},
{},
},
"vars": map[string]any{
"key": "value",
Expand All @@ -120,7 +120,7 @@ func TestBindRunnerRun(t *testing.T) {
},
store{
steps: []map[string]any{
{"run": true},
{},
},
vars: map[string]any{
"key": "value",
Expand All @@ -131,7 +131,7 @@ func TestBindRunnerRun(t *testing.T) {
},
map[string]any{
"steps": []map[string]any{
{"run": true},
{},
},
"vars": map[string]any{
"key": "value",
Expand All @@ -157,7 +157,7 @@ func TestBindRunnerRun(t *testing.T) {
},
store{
steps: []map[string]any{
{"run": true},
{},
},
vars: map[string]any{
"key": "value",
Expand All @@ -171,7 +171,7 @@ func TestBindRunnerRun(t *testing.T) {
},
map[string]any{
"steps": []map[string]any{
{"run": true},
{},
},
"vars": map[string]any{
"key": "value",
Expand Down Expand Up @@ -201,7 +201,7 @@ func TestBindRunnerRun(t *testing.T) {
},
store{
steps: []map[string]any{
{"run": true},
{},
},
vars: map[string]any{
"key": "value",
Expand All @@ -219,7 +219,7 @@ func TestBindRunnerRun(t *testing.T) {
},
map[string]any{
"steps": []map[string]any{
{"run": true},
{},
},
"vars": map[string]any{
"key": "value",
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestBindRunnerRun(t *testing.T) {
},
store{
steps: []map[string]any{
{"run": true},
{},
},
vars: map[string]any{
"key": "value",
Expand All @@ -262,7 +262,7 @@ func TestBindRunnerRun(t *testing.T) {
},
map[string]any{
"steps": []map[string]any{
{"run": true},
{},
},
"vars": map[string]any{
"key": "value",
Expand Down
5 changes: 0 additions & 5 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestDBRunner(t *testing.T) {
"rows": []map[string]any{
{"1": int64(1)},
},
"run": true,
},
},
{
Expand All @@ -31,7 +30,6 @@ func TestDBRunner(t *testing.T) {
"rows": []map[string]any{
{"2": int64(2)},
},
"run": true,
},
},
{
Expand All @@ -47,7 +45,6 @@ INSERT INTO users (username, password, email, created) VALUES ('alice', 'passw0r
map[string]any{
"last_insert_id": int64(1),
"rows_affected": int64(1),
"run": true,
},
},
{
Expand All @@ -66,7 +63,6 @@ SELECT COUNT(*) AS count FROM users;
"rows": []map[string]any{
{"count": int64(1)},
},
"run": true,
},
},
{
Expand Down Expand Up @@ -106,7 +102,6 @@ SELECT * FROM users;
},
},
},
"run": true,
},
},
}
Expand Down
2 changes: 0 additions & 2 deletions exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ func TestExecRun(t *testing.T) {
"stdout": "hello!!\n",
"stderr": "",
"exit_code": 0,
"run": true,
}},
{"cat", "hello!!", "", map[string]any{
"stdout": "hello!!",
"stderr": "",
"exit_code": 0,
"run": true,
}},
}
ctx := context.Background()
Expand Down
2 changes: 0 additions & 2 deletions operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ func (o *operator) recordNotRun(i int) {
return
}
v := map[string]any{}
v[storeStepKeyRun] = false
if o.useMap {
o.recordAsMapped(v)
return
Expand All @@ -349,7 +348,6 @@ func (o *operator) record(v map[string]any) {
if v == nil {
v = map[string]any{}
}
v[storeStepKeyRun] = true
if o.useMap {
o.recordAsMapped(v)
return
Expand Down
57 changes: 17 additions & 40 deletions operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,20 +1142,19 @@ func TestStepResult(t *testing.T) {
}
}

func TestStepOutcomeAndRun(t *testing.T) {
func TestStepOutcome(t *testing.T) {
tests := []struct {
book string
force bool
wantOutcome []result
wantRun []bool
book string
force bool
want []result
}{
{"testdata/book/always_success.yml", false, []result{resultSuccess, resultSuccess, resultSuccess}, []bool{true, true, true}},
{"testdata/book/always_failure.yml", false, []result{resultSuccess, resultFailure, resultSkipped}, []bool{true, false, false}},
{"testdata/book/skip_test.yml", false, []result{resultSkipped, resultSuccess}, []bool{false, true}},
{"testdata/book/only_if_included.yml", false, []result{resultSkipped, resultSkipped}, []bool{false, false}},
{"testdata/book/always_failure.yml", true, []result{resultSuccess, resultFailure, resultSuccess}, []bool{true, false, true}},
{"testdata/book/only_if_included.yml", true, []result{resultSkipped, resultSkipped}, []bool{false, false}},
{"testdata/book/always_success_loop.yml", false, []result{resultSuccess, resultSuccess, resultSuccess}, []bool{true, true, true}},
{"testdata/book/always_success.yml", false, []result{resultSuccess, resultSuccess, resultSuccess}},
{"testdata/book/always_failure.yml", false, []result{resultSuccess, resultFailure, resultSkipped}},
{"testdata/book/skip_test.yml", false, []result{resultSkipped, resultSuccess}},
{"testdata/book/only_if_included.yml", false, []result{resultSkipped, resultSkipped}},
{"testdata/book/always_failure.yml", true, []result{resultSuccess, resultFailure, resultSuccess}},
{"testdata/book/only_if_included.yml", true, []result{resultSkipped, resultSkipped}},
{"testdata/book/always_success_loop.yml", false, []result{resultSuccess, resultSuccess, resultSuccess}},
}
ctx := context.Background()
for _, tt := range tests {
Expand All @@ -1167,8 +1166,8 @@ func TestStepOutcomeAndRun(t *testing.T) {
}
_ = o.Run(ctx)
if o.useMap {
if len(o.store.stepMapKeys) != len(tt.wantOutcome) {
t.Errorf("got %v\nwant %v", len(o.store.stepMapKeys), len(tt.wantOutcome))
if len(o.store.stepMapKeys) != len(tt.want) {
t.Errorf("got %v\nwant %v", len(o.store.stepMapKeys), len(tt.want))
}
i := 0
for _, k := range o.store.stepMapKeys {
Expand All @@ -1177,48 +1176,26 @@ func TestStepOutcomeAndRun(t *testing.T) {
t.Error("want outcome")
continue
}
want := tt.wantOutcome[i]
want := tt.want[i]
if got != want {
t.Errorf("step[%d] got %v\nwant %v", i, got, want)
}
{
got, ok := o.store.stepMap[k][storeStepKeyRun]
if !ok {
t.Error("want run result")
continue
}
want := tt.wantRun[i]
if got != want {
t.Errorf("step[%d] got %v\nwant %v", i, got, want)
}
}
i++
}
} else {
if len(o.store.steps) != len(tt.wantOutcome) {
t.Errorf("got %v\nwant %v", len(o.store.steps), len(tt.wantOutcome))
if len(o.store.steps) != len(tt.want) {
t.Errorf("got %v\nwant %v", len(o.store.steps), len(tt.want))
}
for i, s := range o.store.steps {
got, ok := s[storeStepKeyOutcome]
if !ok {
t.Error("want outcome")
continue
}
want := tt.wantOutcome[i]
want := tt.want[i]
if got != want {
t.Errorf("step[%d] got %v\nwant %v", i, got, want)
}
{
got, ok := s[storeStepKeyRun]
if !ok {
t.Error("want run result")
continue
}
want := tt.wantRun[i]
if got != want {
t.Errorf("step[%d] got %v\nwant %v", i, got, want)
}
}
}
}
})
Expand Down
1 change: 0 additions & 1 deletion store.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const (
)

const (
storeStepKeyRun = "run"
storeStepKeyOutcome = "outcome"
)

Expand Down

0 comments on commit 986a857

Please sign in to comment.