19146: Remove unneeded special case checks, explain the needed one.
[arvados.git] / lib / install / deps_go_version_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package install
6
7 import (
8         "bytes"
9         "os/exec"
10         "testing"
11
12         "gopkg.in/check.v1"
13 )
14
15 func Test(t *testing.T) {
16         check.TestingT(t)
17 }
18
19 var _ = check.Suite(&Suite{})
20
21 type Suite struct{}
22
23 /*
24         TestExtractGoVersion tests the grep/awk command used in
25         tools/arvbox/bin/arvbox to extract the version of Go to install for
26         bootstrapping `arvados-server`.
27
28         If this test is changed, the arvbox code will also need to be updated.
29 */
30 func (*Suite) TestExtractGoVersion(c *check.C) {
31         script := `
32   sourcepath="$(realpath ../..)"
33   (cd ${sourcepath} && grep 'const goversion =' lib/install/deps.go |awk -F'"' '{print $2}')
34         `
35         cmd := exec.Command("bash", "-")
36         cmd.Stdin = bytes.NewBufferString("set -ex -o pipefail\n" + script)
37         cmdOutput, err := cmd.Output()
38         c.Assert(err, check.IsNil)
39         c.Assert(string(cmdOutput), check.Equals, goversion+"\n")
40 }