Skip to content

Commit

Permalink
Merge pull request #1139 from k1LoW/refactor-store
Browse files Browse the repository at this point in the history
Refactor internal/store
  • Loading branch information
k1LoW authored Dec 31, 2024
2 parents e413781 + 1ad4601 commit bd98d85
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 146 deletions.
28 changes: 14 additions & 14 deletions bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ func TestBindRunnerRun(t *testing.T) {
}{
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
map[string]any{},
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.Record(0, map[string]any{})
return s
Expand All @@ -42,7 +42,7 @@ func TestBindRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -51,7 +51,7 @@ func TestBindRunnerRun(t *testing.T) {
"newkey": "vars.key",
},
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
if err := s.SetBindVar("newkey", "value"); err != nil {
Expand All @@ -75,7 +75,7 @@ func TestBindRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -84,7 +84,7 @@ func TestBindRunnerRun(t *testing.T) {
"newkey": "'hello'",
},
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
if err := s.SetBindVar("newkey", "hello"); err != nil {
Expand All @@ -108,7 +108,7 @@ func TestBindRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -117,7 +117,7 @@ func TestBindRunnerRun(t *testing.T) {
"newkey": []any{"vars.key", 4, "'hello'"},
},
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
if err := s.SetBindVar("newkey", []any{"value", 4, "hello"}); err != nil {
Expand All @@ -141,7 +141,7 @@ func TestBindRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -153,7 +153,7 @@ func TestBindRunnerRun(t *testing.T) {
},
},
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
if err := s.SetBindVar("newkey", map[string]any{
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestBindRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -196,7 +196,7 @@ func TestBindRunnerRun(t *testing.T) {
"bar[]": "'six'",
},
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
if err := s.SetBindVar("foo", map[any]any{
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestBindRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
if err := s.SetBindVar("bar", []any{"six"}); err != nil {
Expand All @@ -248,7 +248,7 @@ func TestBindRunnerRun(t *testing.T) {
"bar[]": "'seven'",
},
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
if err := s.SetBindVar("bar", []any{"six", "seven"}); err != nil {
Expand Down
54 changes: 27 additions & 27 deletions dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDumpRunnerRun(t *testing.T) {
}{
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
Expand All @@ -35,7 +35,7 @@ func TestDumpRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -48,7 +48,7 @@ func TestDumpRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -63,7 +63,7 @@ func TestDumpRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -80,7 +80,7 @@ func TestDumpRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, true, []string{"stepkey", "stepnext"})
s := store.New(map[string]any{}, map[string]any{}, nil, []string{"stepkey", "stepnext"})
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -100,7 +100,7 @@ func TestDumpRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -115,7 +115,7 @@ func TestDumpRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, true, []string{"0", "1"})
s := store.New(map[string]any{}, map[string]any{}, nil, []string{"0", "1"})
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -133,7 +133,7 @@ func TestDumpRunnerRun(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
}{
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
Expand All @@ -197,7 +197,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -210,7 +210,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -225,7 +225,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -242,7 +242,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, true, []string{"stepkey", "stepnext"})
s := store.New(map[string]any{}, map[string]any{}, nil, []string{"stepkey", "stepnext"})
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -262,7 +262,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -277,7 +277,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, true, []string{"0", "1"})
s := store.New(map[string]any{}, map[string]any{}, nil, []string{"0", "1"})
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -295,7 +295,7 @@ func TestDumpRunnerRunWithOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
Expand Down Expand Up @@ -360,7 +360,7 @@ func TestDumpRunnerRunWithExpandOut(t *testing.T) {
}{
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
Expand All @@ -369,7 +369,7 @@ func TestDumpRunnerRunWithExpandOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
Expand All @@ -378,7 +378,7 @@ func TestDumpRunnerRunWithExpandOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", filepath.Join(tmp, "value"))
return s
Expand All @@ -388,7 +388,7 @@ func TestDumpRunnerRunWithExpandOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", filepath.Join(tmp, "value2"))
return s
Expand All @@ -398,7 +398,7 @@ func TestDumpRunnerRunWithExpandOut(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", filepath.Join(tmp, "value3"))
return s
Expand Down Expand Up @@ -444,7 +444,7 @@ func TestDumpRunnerRunWithSecrets(t *testing.T) {
}{
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -458,7 +458,7 @@ func TestDumpRunnerRunWithSecrets(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -474,7 +474,7 @@ func TestDumpRunnerRunWithSecrets(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -492,7 +492,7 @@ func TestDumpRunnerRunWithSecrets(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, true, []string{"stepkey", "stepnext"})
s := store.New(map[string]any{}, map[string]any{}, nil, []string{"stepkey", "stepnext"})
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand All @@ -513,7 +513,7 @@ func TestDumpRunnerRunWithSecrets(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("key", "value")
return s
Expand All @@ -527,7 +527,7 @@ func TestDumpRunnerRunWithSecrets(t *testing.T) {
},
{
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, true, []string{"stepkey", "stepnext"})
s := store.New(map[string]any{}, map[string]any{}, nil, []string{"stepkey", "stepnext"})
s.SetRunNIndex(0)
s.Record(0, map[string]any{"key": "value"})
return s
Expand Down
6 changes: 3 additions & 3 deletions include_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestUseParentStore(t *testing.T) {
"Use parent store in vars: section",
"testdata/book/use_parent_store_vars.yml",
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("foo", "bar")
return s
Expand All @@ -193,7 +193,7 @@ func TestUseParentStore(t *testing.T) {
"Error if there is no parent store",
"testdata/book/use_parent_store_vars.yml",
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
return s
}(),
Expand All @@ -203,7 +203,7 @@ func TestUseParentStore(t *testing.T) {
"Use parent store in runners: section",
"testdata/book/use_parent_store_runners.yml",
func() *store.Store {
s := store.New(map[string]any{}, map[string]any{}, nil, false, nil)
s := store.New(map[string]any{}, map[string]any{}, nil, nil)
s.SetRunNIndex(0)
s.SetVar("httprunner", host)
return s
Expand Down
Loading

0 comments on commit bd98d85

Please sign in to comment.