1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 "git.arvados.org/arvados.git/lib/cmd"
13 check "gopkg.in/check.v1"
16 // Gocheck boilerplate
17 func Test(t *testing.T) {
21 var _ = check.Suite(&ClientSuite{})
23 type ClientSuite struct{}
25 func (s *ClientSuite) TestBadCommand(c *check.C) {
26 exited := handler.RunCommand("arvados-client", []string{"no such command"}, bytes.NewReader(nil), ioutil.Discard, ioutil.Discard)
27 c.Check(exited, check.Equals, cmd.EXIT_INVALIDARGUMENT)
30 func (s *ClientSuite) TestBadSubcommandArgs(c *check.C) {
31 exited := handler.RunCommand("arvados-client", []string{"get"}, bytes.NewReader(nil), ioutil.Discard, ioutil.Discard)
32 c.Check(exited, check.Equals, cmd.EXIT_INVALIDARGUMENT)
35 func (s *ClientSuite) TestVersion(c *check.C) {
36 stdout := bytes.NewBuffer(nil)
37 stderr := bytes.NewBuffer(nil)
38 exited := handler.RunCommand("arvados-client", []string{"version"}, bytes.NewReader(nil), stdout, stderr)
39 c.Check(exited, check.Equals, 0)
40 c.Check(stdout.String(), check.Matches, `arvados-client dev \(go[0-9\.]+\)\n`)
41 c.Check(stderr.String(), check.Equals, "")