From 95911100823b5c809225d664de74ad2d64e91972 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Thu, 22 Dec 2022 23:19:31 +0100 Subject: cache: fix some bugs after refactor --- commands/bug/select/select_test.go | 5 +---- commands/execenv/env.go | 24 +++++++++++------------- commands/execenv/env_testing.go | 5 +---- commands/root.go | 2 +- commands/webui.go | 24 +++++++++++++----------- 5 files changed, 27 insertions(+), 33 deletions(-) (limited to 'commands') diff --git a/commands/bug/select/select_test.go b/commands/bug/select/select_test.go index 5533ac2b..83ca6643 100644 --- a/commands/bug/select/select_test.go +++ b/commands/bug/select/select_test.go @@ -13,11 +13,8 @@ import ( func TestSelect(t *testing.T) { repo := repository.CreateGoGitTestRepo(t, false) - repoCache, events, err := cache.NewRepoCache(repo) + repoCache, err := cache.NewRepoCacheNoEvents(repo) require.NoError(t, err) - for event := range events { - require.NoError(t, event.Err) - } _, _, err = ResolveBug(repoCache, []string{}) require.Equal(t, ErrNoValidId, err) diff --git a/commands/execenv/env.go b/commands/execenv/env.go index 0813ab7e..4c6ce204 100644 --- a/commands/execenv/env.go +++ b/commands/execenv/env.go @@ -136,19 +136,17 @@ func LoadBackend(env *Env) func(*cobra.Command, []string) error { if events != nil { env.Err.Println("Building cache... ") - } - - for event := range events { - if event.Err != nil { - env.Err.Printf("Cache building error [%s]: %v\n", event.Typename, event.Err) - continue - } - - switch event.Event { - case cache.BuildEventStarted: - env.Err.Printf("[%s] started\n", event.Typename) - case cache.BuildEventFinished: - env.Err.Printf("[%s] done\n", event.Typename) + for event := range events { + if event.Err != nil { + env.Err.Printf("Cache building error [%s]: %v\n", event.Typename, event.Err) + continue + } + switch event.Event { + case cache.BuildEventStarted: + env.Err.Printf("[%s] started\n", event.Typename) + case cache.BuildEventFinished: + env.Err.Printf("[%s] done\n", event.Typename) + } } } diff --git a/commands/execenv/env_testing.go b/commands/execenv/env_testing.go index ddba735f..5761b410 100644 --- a/commands/execenv/env_testing.go +++ b/commands/execenv/env_testing.go @@ -34,11 +34,8 @@ func NewTestEnv(t *testing.T) *Env { buf := new(bytes.Buffer) - backend, events, err := cache.NewRepoCache(repo) + backend, err := cache.NewRepoCacheNoEvents(repo) require.NoError(t, err) - for event := range events { - require.NoError(t, event.Err) - } t.Cleanup(func() { backend.Close() diff --git a/commands/root.go b/commands/root.go index b28b77b8..d98f9448 100644 --- a/commands/root.go +++ b/commands/root.go @@ -61,7 +61,7 @@ the same git remote you are already using to collaborate with other people. const remoteGroup = "remote" cmd.AddGroup(&cobra.Group{ID: entityGroup, Title: "Entities"}) - cmd.AddGroup(&cobra.Group{ID: uiGroup, Title: "User interfaces"}) + cmd.AddGroup(&cobra.Group{ID: uiGroup, Title: "Interactive interfaces"}) cmd.AddGroup(&cobra.Group{ID: remoteGroup, Title: "Interaction with the outside world"}) addCmdWithGroup := func(child *cobra.Command, groupID string) { diff --git a/commands/webui.go b/commands/webui.go index 4f7a02b5..6cbaff78 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -110,17 +110,19 @@ func runWebUI(env *execenv.Env, opts webUIOptions) error { return err } - for event := range events { - if event.Err != nil { - env.Err.Printf("Cache building error [%s]: %v\n", event.Typename, event.Err) - continue - } - - switch event.Event { - case cache.BuildEventStarted: - env.Err.Printf("[%s] started\n", event.Typename) - case cache.BuildEventFinished: - env.Err.Printf("[%s] done\n", event.Typename) + if events != nil { + env.Err.Println("Building cache... ") + for event := range events { + if event.Err != nil { + env.Err.Printf("Cache building error [%s]: %v\n", event.Typename, event.Err) + continue + } + switch event.Event { + case cache.BuildEventStarted: + env.Err.Printf("[%s] started\n", event.Typename) + case cache.BuildEventFinished: + env.Err.Printf("[%s] done\n", event.Typename) + } } } -- cgit