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
This commit is contained in:
Jo 2023-02-17 20:29:46 +01:00 committed by GitHub
parent 0bf4c2e502
commit 0a8bc1fe2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 18 deletions

View File

@ -30,17 +30,17 @@ func (l *Logger) Debugln(a ...any) {
return return
} }
fmt.Fprintln(l.w, append([]interface{}{ l.Println(append([]interface{}{
Bold(yellow(fmt.Sprintf("[DEBUG:%s]", l.name))), Bold(yellow(fmt.Sprintf("[DEBUG:%s]", l.name))),
}, a...)...) }, a...)...)
} }
func (l *Logger) OperationInfoln(a ...any) { func (l *Logger) OperationInfoln(a ...any) {
fmt.Fprintln(l.w, l.SprintOperationInfo(a...)) l.Println(l.SprintOperationInfo(a...))
} }
func (l *Logger) OperationInfo(a ...any) { 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 { func (l *Logger) SprintOperationInfo(a ...any) string {
@ -48,19 +48,19 @@ func (l *Logger) SprintOperationInfo(a ...any) string {
} }
func (l *Logger) Info(a ...any) { 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) { 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) { func (l *Logger) Warn(a ...any) {
fmt.Fprint(l.w, l.SprintWarn(a...)) l.Print(l.SprintWarn(a...))
} }
func (l *Logger) Warnln(a ...any) { 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 { func (l *Logger) SprintWarn(a ...any) string {
@ -68,11 +68,11 @@ func (l *Logger) SprintWarn(a ...any) string {
} }
func (l *Logger) Error(a ...any) { func (l *Logger) Error(a ...any) {
fmt.Fprint(l.w, l.SprintError(a...)) l.Print(l.SprintError(a...))
} }
func (l *Logger) Errorln(a ...any) { 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 { 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) { func (l *Logger) Printf(format string, a ...any) {
fmt.Fprintf(l.w, format, a...) 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...)
}

View File

@ -117,6 +117,7 @@ func (u *UpgradeService) upGraph(ctx context.Context, graph *topo.Graph[string,
Upgrade: true, Upgrade: true,
Devel: true, Devel: true,
LocalVersion: up.LocalVersion, LocalVersion: up.LocalVersion,
Version: up.RemoteVersion,
}) })
names.Add(up.Name) names.Add(up.Name)
} }

View File

@ -28,6 +28,7 @@ func ptrString(s string) *string {
} }
func TestUpgradeService_GraphUpgrades(t *testing.T) { func TestUpgradeService_GraphUpgrades(t *testing.T) {
t.Parallel()
linuxDepInfo := &dep.InstallInfo{ linuxDepInfo := &dep.InstallInfo{
Reason: dep.Explicit, Reason: dep.Explicit,
Source: dep.Sync, Source: dep.Sync,
@ -44,7 +45,7 @@ func TestUpgradeService_GraphUpgrades(t *testing.T) {
Reason: dep.Dep, Reason: dep.Dep,
AURBase: ptrString("example"), AURBase: ptrString("example"),
LocalVersion: "2.2.1.r32.41baa362-1", LocalVersion: "2.2.1.r32.41baa362-1",
Version: "", Version: "latest-commit",
Upgrade: true, Upgrade: true,
Devel: true, Devel: true,
} }
@ -121,13 +122,6 @@ func TestUpgradeService_GraphUpgrades(t *testing.T) {
}, nil }, nil
}, },
} }
grapher := dep.NewGrapher(dbExe, mockAUR,
false, true, io.Discard, false, false)
cfg := &settings.Configuration{
Runtime: &settings.Runtime{Mode: parser.ModeAny},
}
type fields struct { type fields struct {
input io.Reader input io.Reader
output io.Writer output io.Writer
@ -256,7 +250,14 @@ func TestUpgradeService_GraphUpgrades(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { 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{ u := &UpgradeService{
log: text.NewLogger(tt.fields.output, tt.fields.input, true, "test"), log: text.NewLogger(tt.fields.output, tt.fields.input, true, "test"),
grapher: grapher, grapher: grapher,