From 0a8bc1fe2e5e7577d09f59521f889b92cad69d9c Mon Sep 17 00:00:00 2001 From: Jo Date: Fri, 17 Feb 2023 20:29:46 +0100 Subject: [PATCH] fix(new_engine): add missing latest-commit in devel upgrade menu (#1916) * fix missing latest-commit in devel upgrade menu * move test grapher to inner test --- pkg/text/service.go | 26 +++++++++++++++++--------- pkg/upgrade/service.go | 1 + pkg/upgrade/service_test.go | 19 ++++++++++--------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/pkg/text/service.go b/pkg/text/service.go index ada552bd..478e679e 100644 --- a/pkg/text/service.go +++ b/pkg/text/service.go @@ -30,17 +30,17 @@ func (l *Logger) Debugln(a ...any) { return } - fmt.Fprintln(l.w, append([]interface{}{ + l.Println(append([]interface{}{ Bold(yellow(fmt.Sprintf("[DEBUG:%s]", l.name))), }, a...)...) } func (l *Logger) OperationInfoln(a ...any) { - fmt.Fprintln(l.w, l.SprintOperationInfo(a...)) + l.Println(l.SprintOperationInfo(a...)) } func (l *Logger) OperationInfo(a ...any) { - fmt.Fprint(l.w, l.SprintOperationInfo(a...)) + l.Print(l.SprintOperationInfo(a...)) } func (l *Logger) SprintOperationInfo(a ...any) string { @@ -48,19 +48,19 @@ func (l *Logger) SprintOperationInfo(a ...any) string { } func (l *Logger) Info(a ...any) { - fmt.Fprint(l.w, append([]interface{}{Bold(Green(arrow + " "))}, a...)...) + l.Print(append([]interface{}{Bold(Green(arrow + " "))}, a...)...) } func (l *Logger) Infoln(a ...any) { - fmt.Fprintln(l.w, append([]interface{}{Bold(Green(arrow))}, a...)...) + l.Println(append([]interface{}{Bold(Green(arrow))}, a...)...) } func (l *Logger) Warn(a ...any) { - fmt.Fprint(l.w, l.SprintWarn(a...)) + l.Print(l.SprintWarn(a...)) } func (l *Logger) Warnln(a ...any) { - fmt.Fprintln(l.w, l.SprintWarn(a...)) + l.Println(l.SprintWarn(a...)) } func (l *Logger) SprintWarn(a ...any) string { @@ -68,11 +68,11 @@ func (l *Logger) SprintWarn(a ...any) string { } func (l *Logger) Error(a ...any) { - fmt.Fprint(l.w, l.SprintError(a...)) + l.Print(l.SprintError(a...)) } func (l *Logger) Errorln(a ...any) { - fmt.Fprintln(l.w, l.SprintError(a...)) + l.Println(l.SprintError(a...)) } func (l *Logger) SprintError(a ...any) string { @@ -82,3 +82,11 @@ func (l *Logger) SprintError(a ...any) string { func (l *Logger) Printf(format string, a ...any) { fmt.Fprintf(l.w, format, a...) } + +func (l *Logger) Println(a ...any) { + fmt.Fprintln(l.w, a...) +} + +func (l *Logger) Print(a ...any) { + fmt.Fprint(l.w, a...) +} diff --git a/pkg/upgrade/service.go b/pkg/upgrade/service.go index 4e5ed574..28c70299 100644 --- a/pkg/upgrade/service.go +++ b/pkg/upgrade/service.go @@ -117,6 +117,7 @@ func (u *UpgradeService) upGraph(ctx context.Context, graph *topo.Graph[string, Upgrade: true, Devel: true, LocalVersion: up.LocalVersion, + Version: up.RemoteVersion, }) names.Add(up.Name) } diff --git a/pkg/upgrade/service_test.go b/pkg/upgrade/service_test.go index 057aac7b..fb9baa49 100644 --- a/pkg/upgrade/service_test.go +++ b/pkg/upgrade/service_test.go @@ -28,6 +28,7 @@ func ptrString(s string) *string { } func TestUpgradeService_GraphUpgrades(t *testing.T) { + t.Parallel() linuxDepInfo := &dep.InstallInfo{ Reason: dep.Explicit, Source: dep.Sync, @@ -44,7 +45,7 @@ func TestUpgradeService_GraphUpgrades(t *testing.T) { Reason: dep.Dep, AURBase: ptrString("example"), LocalVersion: "2.2.1.r32.41baa362-1", - Version: "", + Version: "latest-commit", Upgrade: true, Devel: true, } @@ -121,13 +122,6 @@ func TestUpgradeService_GraphUpgrades(t *testing.T) { }, nil }, } - grapher := dep.NewGrapher(dbExe, mockAUR, - false, true, io.Discard, false, false) - - cfg := &settings.Configuration{ - Runtime: &settings.Runtime{Mode: parser.ModeAny}, - } - type fields struct { input io.Reader output io.Writer @@ -256,7 +250,14 @@ func TestUpgradeService_GraphUpgrades(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - cfg.Devel = tt.fields.devel + grapher := dep.NewGrapher(dbExe, mockAUR, + false, true, io.Discard, false, false) + + cfg := &settings.Configuration{ + Runtime: &settings.Runtime{Mode: parser.ModeAny}, + Devel: tt.fields.devel, + } + u := &UpgradeService{ log: text.NewLogger(tt.fields.output, tt.fields.input, true, "test"), grapher: grapher,