Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

77 lines (64 sloc) 2.039 kb
package nut_test
import (
. "."
. ""
type N struct {
nf *NutFile
var _ = Suite(&N{})
func (f *N) SetUpTest(c *C) {
file, err := os.Open("../test_nut1/test_nut1-0.0.1.nut")
c.Assert(err, IsNil)
defer file.Close()
fi, err := file.Stat()
c.Assert(err, IsNil)
nf := new(NutFile)
n, err := nf.ReadFrom(file)
c.Assert(err, IsNil)
c.Assert(n, Equals, fi.Size()) = nf
func (f *N) TestNutFileReadFrom(c *C) {
c.Check(, Equals, "0.0.1")
c.Check(, Equals, "0.0.1")
c.Check(, Equals, "debug")
c.Check(, Equals, "test_nut1")
c.Check(, Equals, "test_nut1")
c.Check(, Equals, "test_nut1-0.0.1.nut")
c.Check("prefix"), Equals, filepath.FromSlash("prefix/debug/test_nut1-0.0.1.nut"))
c.Check("prefix"), Equals, "prefix/debug/test_nut1")
c.Check(, Equals, "Package test_nut1 is used to test nut.")
c.Check(, DeepEquals, []string{"test_nut1.go", fmt.Sprintf("test_nut1_%s.go", runtime.GOOS)})
c.Check(len(, Equals, 11)
names := make([]string, 0, 11)
for _, f := range {
names = append(names, f.Name)
c.Check([]string{"test_nut1.go", "test_nut1_darwin.go", "test_nut1_freebsd.go", "test_nut1_linux.go", "test_nut1_netbsd.go",
"test_nut1_openbsd.go", "test_nut1_plan9.go", "test_nut1_windows.go", "README", "LICENSE", "nut.json"},
DeepEquals, names)
func (f *N) TestNutFileReadFile(c *C) {
nf := new(NutFile)
err := nf.ReadFile("../test_nut1/test_nut1-0.0.1.nut")
c.Check(err, IsNil)
c.Check(nf, DeepEquals,
func (f *N) TestNutReadFrom(c *C) {
pwd, err := os.Getwd()
c.Assert(err, IsNil)
c.Assert(os.Chdir("../test_nut1"), IsNil)
defer func() {
c.Assert(os.Chdir(pwd), IsNil)
nut := new(Nut)
err = nut.ReadFrom(".")
c.Check(err, IsNil)
c.Check(nut.Spec, DeepEquals,
c.Check(nut.Package, DeepEquals,
Jump to Line
Something went wrong with that request. Please try again.