mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-18 19:16:22 +00:00
* fix: make patch list registry-only * feat: add patch command progress logs * fix: address review feedback for PR #921
44 lines
881 B
Go
44 lines
881 B
Go
package cmd
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func TestCommandProgressWritesHumanUpdatesToStderr(t *testing.T) {
|
|
oldJSONOut := jsonOut
|
|
t.Cleanup(func() {
|
|
jsonOut = oldJSONOut
|
|
})
|
|
jsonOut = false
|
|
|
|
var stderr bytes.Buffer
|
|
cmd := &cobra.Command{}
|
|
cmd.SetErr(&stderr)
|
|
|
|
progress := commandProgress(cmd)
|
|
if progress == nil {
|
|
t.Fatalf("expected human progress reporter")
|
|
}
|
|
progress.Step("Applying 1 patch operation")
|
|
|
|
if !strings.Contains(stderr.String(), "Applying 1 patch operation") {
|
|
t.Fatalf("expected progress on stderr, got %q", stderr.String())
|
|
}
|
|
}
|
|
|
|
func TestCommandProgressDisabledForJSON(t *testing.T) {
|
|
oldJSONOut := jsonOut
|
|
t.Cleanup(func() {
|
|
jsonOut = oldJSONOut
|
|
})
|
|
jsonOut = true
|
|
|
|
if progress := commandProgress(&cobra.Command{}); progress != nil {
|
|
t.Fatalf("expected nil progress reporter in JSON mode")
|
|
}
|
|
}
|