18657: Don't install api & wb binstubs into bin/
[arvados.git] / cmd / arvados-client / cmd_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package main
6
7 import (
8         "bytes"
9         "io/ioutil"
10         "testing"
11
12         check "gopkg.in/check.v1"
13 )
14
15 // Gocheck boilerplate
16 func Test(t *testing.T) {
17         check.TestingT(t)
18 }
19
20 var _ = check.Suite(&ClientSuite{})
21
22 type ClientSuite struct{}
23
24 func (s *ClientSuite) TestBadCommand(c *check.C) {
25         exited := handler.RunCommand("arvados-client", []string{"no such command"}, bytes.NewReader(nil), ioutil.Discard, ioutil.Discard)
26         c.Check(exited, check.Equals, 2)
27 }
28
29 func (s *ClientSuite) TestBadSubcommandArgs(c *check.C) {
30         exited := handler.RunCommand("arvados-client", []string{"get"}, bytes.NewReader(nil), ioutil.Discard, ioutil.Discard)
31         c.Check(exited, check.Equals, 2)
32 }
33
34 func (s *ClientSuite) TestVersion(c *check.C) {
35         stdout := bytes.NewBuffer(nil)
36         stderr := bytes.NewBuffer(nil)
37         exited := handler.RunCommand("arvados-client", []string{"version"}, bytes.NewReader(nil), stdout, stderr)
38         c.Check(exited, check.Equals, 0)
39         c.Check(stdout.String(), check.Matches, `arvados-client dev \(go[0-9\.]+\)\n`)
40         c.Check(stderr.String(), check.Equals, "")
41 }