diff --git a/io/io_test.go b/io/io_test.go index f3ce991..6a7a135 100644 --- a/io/io_test.go +++ b/io/io_test.go @@ -47,11 +47,6 @@ func TestSelectOutputProcessor(t *testing.T) { // args: []string{"--json-indent", "xx"}, // expected: &errWrapper{&jsonProcessor{indent: "xx"}}, // }, - { - name: "raw output", - args: []string{"-F", "raw"}, - expected: &bytes.Buffer{}, - }, // { // name: "YAML output", // args: []string{"-F", "yaml"}, diff --git a/io/modes.go b/io/modes.go index 8df0eae..b2a268b 100644 --- a/io/modes.go +++ b/io/modes.go @@ -2,7 +2,6 @@ package io import ( "github.com/go-kivik/kouch/io/outputjson" - "github.com/go-kivik/kouch/io/outputraw" "github.com/go-kivik/kouch/io/outputtmpl" "github.com/go-kivik/kouch/io/outputyaml" "github.com/go-kivik/kouch/kouchio" @@ -13,6 +12,5 @@ const defaultOutputMode = "json" var outputModes = map[string]kouchio.OutputMode{ defaultOutputMode: &outputjson.JSONMode{}, "yaml": &outputyaml.YAMLMode{}, - "raw": &outputraw.RawMode{}, "template": &outputtmpl.TmplMode{}, } diff --git a/io/outputraw/raw.go b/io/outputraw/raw.go deleted file mode 100644 index e94c567..0000000 --- a/io/outputraw/raw.go +++ /dev/null @@ -1,22 +0,0 @@ -package outputraw - -import ( - "context" - "io" - - "github.com/go-kivik/kouch/kouchio" - "github.com/spf13/pflag" -) - -// RawMode passes through the output, unaltered. -type RawMode struct{} - -var _ kouchio.OutputMode = &RawMode{} - -// AddFlags does nothing. -func (m *RawMode) AddFlags(_ *pflag.FlagSet) {} - -// New returns w, unaltered. -func (m *RawMode) New(_ context.Context, w io.Writer) (io.Writer, error) { - return w, nil -} diff --git a/io/outputraw/raw_test.go b/io/outputraw/raw_test.go deleted file mode 100644 index a978838..0000000 --- a/io/outputraw/raw_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package outputraw - -import ( - "bytes" - "context" - "io" - "testing" - - "github.com/flimzy/diff" - "github.com/flimzy/testy" - "github.com/go-kivik/kouch" - "github.com/go-kivik/kouch/internal/test" - "github.com/spf13/cobra" -) - -func TestRawModeConfig(t *testing.T) { - cmd := &cobra.Command{} - mode := &RawMode{} - mode.AddFlags(cmd.PersistentFlags()) - - test.Flags(t, []string{}, cmd) -} - -func TestRawNew(t *testing.T) { - tests := []struct { - name string - args []string - parseErr string - expected io.Writer - err string - }{ - { - name: "happy path", - args: nil, - expected: &bytes.Buffer{}, - }, - { - name: "invalid args", - args: []string{"--foo"}, - parseErr: "unknown flag: --foo", - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ctx := context.Background() - cmd := &cobra.Command{} - mode := &RawMode{} - mode.AddFlags(cmd.PersistentFlags()) - - err := cmd.ParseFlags(test.args) - testy.Error(t, test.parseErr, err) - - ctx = kouch.SetFlags(ctx, cmd.Flags()) - result, err := mode.New(ctx, &bytes.Buffer{}) - testy.Error(t, test.err, err) - if d := diff.Interface(test.expected, result); d != nil { - t.Error(d) - } - }) - } -}