implement new 'zrepl status'
Primary goals: - Scrollable output ( fixes #245 ) - Sending job signals from status view - Filtering of output by filesystem Implementation: - original TUI framework: github.com/rivo/tview - but: tview is quasi-unmaintained, didn't support some features - => use fork https://gitlab.com/tslocum/cview - however, don't buy into either too much to avoid lock-in - instead: **port over the existing status UI drawing code and adjust it to produce strings instead of directly drawing into the termbox buffer** Co-authored-by: Calistoc <calistoc@protonmail.com> Co-authored-by: InsanePrawn <insane.prawny@gmail.com> fixes #245 fixes #220
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package choices_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zrepl/zrepl/util/choices"
|
||||
)
|
||||
|
||||
func TestChoices(t *testing.T) {
|
||||
|
||||
var c choices.Choices
|
||||
|
||||
fs := flag.NewFlagSet("testset", flag.ContinueOnError)
|
||||
c.Init("append", os.O_APPEND, "overwrite", os.O_TRUNC|os.O_CREATE)
|
||||
fs.Var(&c, "mode", c.Usage())
|
||||
var o bytes.Buffer
|
||||
fs.SetOutput(&o)
|
||||
|
||||
fs.Usage()
|
||||
usage := o.String()
|
||||
o.Reset()
|
||||
|
||||
t.Logf("usage:\n%s", usage)
|
||||
require.Contains(t, usage, "\"append\"")
|
||||
require.Contains(t, usage, "\"overwrite\"")
|
||||
|
||||
err := fs.Parse([]string{"-mode", "append"})
|
||||
require.NoError(t, err)
|
||||
o.Reset()
|
||||
require.Equal(t, os.O_APPEND, c.Value())
|
||||
|
||||
c.SetDefaultValue(nil)
|
||||
err = fs.Parse([]string{})
|
||||
require.NoError(t, err)
|
||||
o.Reset()
|
||||
require.Nil(t, c.Value())
|
||||
|
||||
// a little whitebox testing: this is allowed ATM, we don't check that the default value was specified as a choice in init
|
||||
c.SetDefaultValue(os.O_RDWR)
|
||||
err = fs.Parse([]string{})
|
||||
require.NoError(t, err)
|
||||
o.Reset()
|
||||
require.Equal(t, os.O_RDWR, c.Value())
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user