From c7a9d3429d2221c9c644ebf8b11103925f88907b Mon Sep 17 00:00:00 2001 From: Slug-Boi Date: Thu, 17 Apr 2025 23:13:44 +0200 Subject: [PATCH] test: add scope and set scope to be local in all tests --- src/cmd/tui/tui_list.go | 7 +++++-- src/cmd/tui/tui_test.go | 18 +++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/cmd/tui/tui_list.go b/src/cmd/tui/tui_list.go index dd6aae7..bf65b39 100644 --- a/src/cmd/tui/tui_list.go +++ b/src/cmd/tui/tui_list.go @@ -387,7 +387,7 @@ func (m Model) View() string { const title_text = "Select authors to add to commit \t|\t" -func listModel() Model { +func listModel(scope ...int) Model { selected = map[string]item{} @@ -396,7 +396,10 @@ func listModel() Model { listKeys := newListKeyMap() // Add items to the list - items := generate_list(git_scope) + if len(scope) == 0 { + scope = append(scope, git_scope) + } + items := generate_list(scope[0]) sort.Slice(items, func(i, j int) bool { return items[i].(item) < items[j].(item) diff --git a/src/cmd/tui/tui_test.go b/src/cmd/tui/tui_test.go index 130b105..3e7e306 100644 --- a/src/cmd/tui/tui_test.go +++ b/src/cmd/tui/tui_test.go @@ -127,7 +127,7 @@ func TestEntryTA(t *testing.T) { setup() defer teardown() - m := listModel() + m := listModel(local_scope) // m := tempAuthorModel(&old_m) tm := teatest.NewTestModel( @@ -218,7 +218,7 @@ func Test_EntryCA_TriggerError(t *testing.T) { setup() defer teardown() - m := listModel() + m := listModel(local_scope) tm := teatest.NewTestModel( t, m, teatest.WithInitialTermSize(300, 300), @@ -256,7 +256,7 @@ func Test_EntryCA(t *testing.T) { setup() defer teardown() - m := listModel() + m := listModel(local_scope) // mm := createAuthorModel(&m) tm := teatest.NewTestModel( @@ -598,7 +598,7 @@ func Test_EntrySelectUsers(t *testing.T) { utils.Define_users("author_file_test") - m := listModel() + m := listModel(local_scope) tm := teatest.NewTestModel( t, m, teatest.WithInitialTermSize(300, 300), ) @@ -628,7 +628,7 @@ func Test_EntrySelectAll(t *testing.T) { utils.Define_users("author_file_test") - m := listModel() + m := listModel(local_scope) tm := teatest.NewTestModel( t, m, teatest.WithInitialTermSize(300, 300), ) @@ -657,7 +657,7 @@ func Test_EntryNegation(t *testing.T) { utils.Define_users("author_file_test") - m := listModel() + m := listModel(local_scope) tm := teatest.NewTestModel( t, m, teatest.WithInitialTermSize(300, 300), ) @@ -686,7 +686,7 @@ func Test_EntryDeleteAuthor(t *testing.T) { utils.Define_users("author_file_test") - m := listModel() + m := listModel(local_scope) tm := teatest.NewTestModel( t, m, teatest.WithInitialTermSize(300, 300), ) @@ -719,7 +719,7 @@ func Test_GroupSelection(t *testing.T) { setup() defer teardown() - m := listModel() + m := listModel(local_scope) tm := teatest.NewTestModel( t, m, teatest.WithInitialTermSize(300, 300), ) @@ -756,7 +756,7 @@ func Test_pagination(t *testing.T) { } } - m := listModel() + m := listModel(local_scope) tm := teatest.NewTestModel( t, m, teatest.WithInitialTermSize(25, 25),