Merge branch 'MajewskiKrzysztof/use_api_token_from_config_object'
[arvados.git] / cmd / arvados-package / build_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package main
6
7 import (
8         "os"
9         "os/exec"
10         "testing"
11
12         "gopkg.in/check.v1"
13 )
14
15 var buildimage string
16
17 func init() {
18         os.Args = append(os.Args, "-test.timeout=30m") // kludge
19 }
20
21 type BuildSuite struct{}
22
23 var _ = check.Suite(&BuildSuite{})
24
25 func Test(t *testing.T) { check.TestingT(t) }
26
27 func (s *BuildSuite) TestBuildAndInstall(c *check.C) {
28         if testing.Short() {
29                 c.Skip("skipping docker tests in short mode")
30         } else if _, err := exec.Command("docker", "info").CombinedOutput(); err != nil {
31                 c.Skip("skipping docker tests because docker is not available")
32         }
33
34         tmpdir := c.MkDir()
35         defer os.RemoveAll(tmpdir)
36         err := os.Chmod(tmpdir, 0755)
37         c.Assert(err, check.IsNil)
38
39         cmd := exec.Command("go", "run", ".",
40                 "build",
41                 "-package-dir", tmpdir,
42                 "-package-version", "1.2.3~rc4",
43                 "-source", "../..",
44         )
45         cmd.Stdout = os.Stderr
46         cmd.Stderr = os.Stderr
47         err = cmd.Run()
48         c.Check(err, check.IsNil)
49
50         fi, err := os.Stat(tmpdir + "/arvados-server-easy_1.2.3~rc4_amd64.deb")
51         c.Assert(err, check.IsNil)
52         c.Logf("%#v", fi)
53
54         buf, _ := exec.Command("ls", "-l", tmpdir).CombinedOutput()
55         c.Logf("%s", buf)
56
57         cmd = exec.Command("go", "run", ".",
58                 "testinstall",
59                 "-package-dir", tmpdir,
60                 "-package-version", "1.2.3~rc4",
61         )
62         cmd.Stdout = os.Stderr
63         cmd.Stderr = os.Stderr
64         err = cmd.Run()
65         c.Check(err, check.IsNil)
66
67         err = os.RemoveAll(tmpdir)
68         c.Check(err, check.IsNil)
69 }