This commit introduces a TDD testing framework for the `collect` commands and resolves a build failure. - A `TDD/` directory has been added to house tests for the `collect` commands. - An environment variable `BORG_PLEXSUS=0` has been implemented to enable a mock mode, which prevents external network calls during testing. - The `collect` commands have been updated to use the command's output streams, allowing for output capturing in tests. - A `pkg/mocks` package has been added to provide mock implementations for testing. - The `.gitignore` file has been updated to exclude generated `.datanode` files. - The "flag redefined" build error has been fixed by refactoring the root command initialization in `cmd/root.go` to prevent duplicate flag definitions.
21 lines
405 B
Go
21 lines
405 B
Go
|
|
package ui
|
|
|
|
import "github.com/schollz/progressbar/v3"
|
|
|
|
type progressWriter struct {
|
|
bar *progressbar.ProgressBar
|
|
}
|
|
|
|
func NewProgressWriter(bar *progressbar.ProgressBar) *progressWriter {
|
|
return &progressWriter{bar: bar}
|
|
}
|
|
|
|
func (pw *progressWriter) Write(p []byte) (n int, err error) {
|
|
if pw == nil || pw.bar == nil {
|
|
return len(p), nil
|
|
}
|
|
s := string(p)
|
|
pw.bar.Describe(s)
|
|
return len(p), nil
|
|
}
|