forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependencies_test.go
47 lines (38 loc) · 1.01 KB
/
dependencies_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package juju_test
import (
"go/build"
"io/ioutil"
"path/filepath"
"strings"
"testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
)
func Test(t *testing.T) {
gc.TestingT(t)
}
type dependenciesTest struct{}
var _ = gc.Suite(&dependenciesTest{})
func projectRoot(c *gc.C) string {
p, err := build.Import("github.com/juju/juju", "", build.FindOnly)
c.Assert(err, jc.ErrorIsNil)
return p.Dir
}
func (*dependenciesTest) TestDependenciesTsvFormat(c *gc.C) {
filename := filepath.Join(projectRoot(c), "dependencies.tsv")
content, err := ioutil.ReadFile(filename)
c.Assert(err, jc.ErrorIsNil)
for _, line := range strings.Split(string(content), "\n") {
if line == "" {
continue
}
segments := strings.Split(line, "\t")
c.Assert(segments, gc.HasLen, 4)
for _, seg := range segments {
c.Assert(strings.HasPrefix(seg, " "), jc.IsFalse)
c.Assert(strings.HasSuffix(seg, " "), jc.IsFalse)
}
}
}