github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/dependencies_test.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package juju_test
     5  
     6  import (
     7  	"go/build"
     8  	"io/ioutil"
     9  	"path/filepath"
    10  	"strings"
    11  	"testing"
    12  
    13  	gc "launchpad.net/gocheck"
    14  )
    15  
    16  func Test(t *testing.T) {
    17  	gc.TestingT(t)
    18  }
    19  
    20  type dependenciesTest struct{}
    21  
    22  var _ = gc.Suite(&dependenciesTest{})
    23  
    24  func projectRoot(c *gc.C) string {
    25  	p, err := build.Import("github.com/juju/juju", "", build.FindOnly)
    26  	c.Assert(err, gc.IsNil)
    27  	return p.Dir
    28  }
    29  
    30  func (*dependenciesTest) TestDependenciesTsvFormat(c *gc.C) {
    31  	filename := filepath.Join(projectRoot(c), "dependencies.tsv")
    32  	content, err := ioutil.ReadFile(filename)
    33  	c.Assert(err, gc.IsNil)
    34  
    35  	for _, line := range strings.Split(string(content), "\n") {
    36  		if line == "" {
    37  			continue
    38  		}
    39  		segments := strings.Split(line, "\t")
    40  		c.Assert(segments, gc.HasLen, 4)
    41  	}
    42  }