コード例 #1
0
ファイル: parser_test.go プロジェクト: npadmana/goconvey
func TestParser(t *testing.T) {
	var (
		parser   *Parser
		packages = []*contract.Package{
			&contract.Package{Active: true, Output: "Active!", Result: contract.NewPackageResult("asdf")},
			&contract.Package{Active: false, Output: "Inactive!", Result: contract.NewPackageResult("qwer")},
		}
	)

	Convey("Subject: Parser parses test output for active packages", t, func() {
		parser = NewParser(fakeParserImplementation)

		Convey("When given a collection of packages", func() {
			parser.Parse(packages)

			Convey("The parser uses its internal parsing mechanism to parse the output of only the active packages", func() {
				So(packages[0].Result.Outcome, ShouldEqual, packages[0].Output)
			})

			Convey("The parser should mark inactive packages as ignored", func() {
				So(packages[1].Result.Outcome, ShouldEqual, contract.Ignored)
			})
		})
	})
}
コード例 #2
0
ファイル: parser_test.go プロジェクト: FihlaTV/bridge-server
func TestParser(t *testing.T) {

	Convey("Subject: Parser parses test output for active packages", t, func() {
		packages := []*contract.Package{
			&contract.Package{Ignored: false, Output: "Active", Result: contract.NewPackageResult("asdf")},
			&contract.Package{Ignored: true, Output: "Inactive", Result: contract.NewPackageResult("qwer")},
		}
		parser := NewParser(fakeParserImplementation)

		Convey("When given a collection of packages", func() {
			parser.Parse(packages)

			Convey("The parser uses its internal parsing mechanism to parse the output of only the active packages", func() {
				So(packages[0].Result.Outcome, ShouldEqual, packages[0].Output)
			})

			Convey("The parser should mark inactive packages as ignored", func() {
				So(packages[1].Result.Outcome, ShouldEqual, contract.Ignored)
			})
		})

		Convey("When a package could not be tested (maybe it was deleted between scanning and execution?)", func() {
			packages[0].Output = ""
			packages[0].Error = errors.New("Directory does not exist")

			parser.Parse(packages)

			Convey("The package result should not be parsed and the outcome should actually resemble the problem", func() {
				So(packages[0].Result.Outcome, ShouldEqual, contract.TestRunAbortedUnexpectedly)
			})
		})
	})
}
コード例 #3
0
ファイル: watcher.go プロジェクト: newobject/goconvey
func (self *Watcher) WatchedFolders() []*contract.Package {
	i, watched := 0, make([]*contract.Package, len(self.watched))
	log.Println("Number of watched folders:", len(self.watched))
	for _, item := range self.watched {
		watched[i] = &contract.Package{
			Active: item.Active,
			Path:   item.Path,
			Name:   item.Name,
			Result: contract.NewPackageResult(item.Name),
		}
		i++
	}
	return watched
}
コード例 #4
0
ファイル: watcher_test.go プロジェクト: himanshugpt/evergreen
func (self *watcherFixture) pointToExistingRootWithNestedFolders() (actual, expected interface{}) {
	self.files.Create(goProject, 1, time.Now())
	self.files.Create(goProject+normalize("/sub"), 2, time.Now())
	self.files.Create(goProject+normalize("/sub2"), 3, time.Now())
	self.files.Create(goProject+normalize("/sub/subsub"), 4, time.Now())

	self.watcher.Adjust(goProject)

	actual = self.watched()
	expected = []*contract.Package{
		&contract.Package{
			Active: true,
			Path:   goProject,
			Name:   goPackagePrefix,
			Result: contract.NewPackageResult(goPackagePrefix),
		},
		&contract.Package{
			Active: true,
			Path:   goProject + normalize("/sub"),
			Name:   goPackagePrefix + normalize("/sub"),
			Result: contract.NewPackageResult(goPackagePrefix + normalize("/sub")),
		},
		&contract.Package{
			Active: true,
			Path:   goProject + normalize("/sub/subsub"),
			Name:   goPackagePrefix + normalize("/sub/subsub"),
			Result: contract.NewPackageResult(goPackagePrefix + normalize("/sub/subsub")),
		},
		&contract.Package{
			Active: true,
			Path:   goProject + normalize("/sub2"),
			Name:   goPackagePrefix + normalize("/sub2"),
			Result: contract.NewPackageResult(goPackagePrefix + normalize("/sub2")),
		},
	}
	return
}
コード例 #5
0
ファイル: watcher_test.go プロジェクト: devsaurin/mongo-tools
func (self *watcherFixture) reinstateIgnoredFolder() (actual, expected interface{}) {
	self.files.Create(goProject, 1, time.Now())
	self.files.Create(goProject+"/sub", 2, time.Now())
	self.watcher.Adjust(goProject)
	self.watcher.Ignore(goPackagePrefix + "/sub")

	self.watcher.Reinstate(goProject + "/sub")

	actual = self.watched()
	expected = []*contract.Package{
		&contract.Package{Active: true, Path: goProject, Name: goPackagePrefix, Result: contract.NewPackageResult(goPackagePrefix)},
		&contract.Package{Active: true, Path: goProject + "/sub", Name: goPackagePrefix + "/sub", Result: contract.NewPackageResult(goPackagePrefix + "/sub")},
	}
	return
}
コード例 #6
0
ファイル: watcher_test.go プロジェクト: himanshugpt/evergreen
func (self *watcherFixture) pointToExistingRoot(folder string) (actual, expected interface{}) {
	self.files.Create(folder, 1, time.Now())

	self.watcher.Adjust(folder)

	actual = self.watched()
	expected = []*contract.Package{
		&contract.Package{
			Active: true,
			Path:   goProject,
			Name:   goPackagePrefix,
			Result: contract.NewPackageResult(goPackagePrefix),
		},
	}
	return
}
コード例 #7
0
ファイル: watcher_test.go プロジェクト: himanshugpt/evergreen
func (self *watcherFixture) reinstateIrrelevantFolder() (actual, expected interface{}) {
	self.files.Create(goProject, 1, time.Now())
	self.files.Create(normalize("/irrelevant"), 2, time.Now())
	self.watcher.Adjust(goProject)

	self.watcher.Reinstate(normalize("/irrelevant"))

	actual = self.watched()
	expected = []*contract.Package{
		&contract.Package{
			Active: true,
			Path:   goProject,
			Name:   goPackagePrefix,
			Result: contract.NewPackageResult(goPackagePrefix),
		},
	}
	return
}
コード例 #8
0
ファイル: watcher_test.go プロジェクト: himanshugpt/evergreen
func (self *watcherFixture) reinstateIgnoredFolders() (actual, expected interface{}) {
	self.files.Create(goProject, 1, time.Now())
	self.files.Create(goProject+normalize("/sub"), 2, time.Now())
	self.files.Create(goProject+normalize("/sub2"), 3, time.Now())
	self.files.Create(goProject+normalize("/sub3"), 4, time.Now())
	self.watcher.Adjust(goProject)
	self.watcher.Ignore(goPackagePrefix + normalize("/sub;") + goPackagePrefix + normalize("/sub2;") + goPackagePrefix + normalize("/sub3"))

	self.watcher.Reinstate(goProject + normalize("/sub;") + goPackagePrefix + normalize("/sub3"))

	actual = self.watched()
	expected = []*contract.Package{
		&contract.Package{Active: true, Path: goProject, Name: goPackagePrefix, Result: contract.NewPackageResult(goPackagePrefix)},
		&contract.Package{Active: true, Path: goProject + normalize("/sub"), Name: goPackagePrefix + normalize("/sub"), Result: contract.NewPackageResult(goPackagePrefix + normalize("/sub"))},
		&contract.Package{Active: false, Path: goProject + normalize("/sub2"), Name: goPackagePrefix + normalize("/sub2"), Result: contract.NewPackageResult(goPackagePrefix + normalize("/sub2"))},
		&contract.Package{Active: true, Path: goProject + normalize("/sub3"), Name: goPackagePrefix + normalize("/sub3"), Result: contract.NewPackageResult(goPackagePrefix + normalize("/sub3"))},
	}
	return
}
コード例 #9
0
ファイル: watcher.go プロジェクト: himanshugpt/evergreen
func (self *Watcher) WatchedFolders() []*contract.Package {
	log.Println("Number of watched folders:", len(self.watched))

	paths := []string{}
	for _, item := range self.watched {
		paths = append(paths, item.Path)
	}
	sort.Strings(paths)

	watched := make([]*contract.Package, len(self.watched))
	for i, path := range paths {
		item := self.watched[path]
		watched[i] = &contract.Package{
			Active: item.Active,
			Path:   item.Path,
			Name:   item.Name,
			Result: contract.NewPackageResult(item.Name),
		}
	}
	return watched
}
コード例 #10
0
ファイル: watcher_test.go プロジェクト: devsaurin/mongo-tools
func (self *watcherFixture) ignoreImaginaryFolder() (actual, expected interface{}) {
	self.files.Create(goProject, 1, time.Now())
	self.watcher.Adjust(goProject)

	self.watcher.Ignore("/not/there")

	actual = self.watched()
	expected = []*contract.Package{&contract.Package{Active: true, Path: goProject, Name: goPackagePrefix, Result: contract.NewPackageResult(goPackagePrefix)}}
	return
}
コード例 #11
0
ファイル: watcher_test.go プロジェクト: devsaurin/mongo-tools
func (self *watcherFixture) ignoreWatchedFolders() (actual, expected interface{}) {
	self.watcher.Creation(goProject + "/sub2")
	self.watcher.Creation(goProject + "/sub3")
	self.watcher.Creation(goProject + "/sub4")

	self.watcher.Ignore(goPackagePrefix + "/sub2;" + goPackagePrefix + "/sub4")

	actual = self.watched()
	expected = []*contract.Package{
		&contract.Package{Active: false, Path: goProject + "/sub2", Name: goPackagePrefix + "/sub2", Result: contract.NewPackageResult(goPackagePrefix + "/sub2")},
		&contract.Package{Active: true, Path: goProject + "/sub3", Name: goPackagePrefix + "/sub3", Result: contract.NewPackageResult(goPackagePrefix + "/sub3")},
		&contract.Package{Active: false, Path: goProject + "/sub4", Name: goPackagePrefix + "/sub4", Result: contract.NewPackageResult(goPackagePrefix + "/sub4")},
	}
	return
}
コード例 #12
0
ファイル: watcher_test.go プロジェクト: devsaurin/mongo-tools
func (self *watcherFixture) receiveNotificationOfDeletedFolder() (actual, expected interface{}) {
	self.watcher.Creation(goProject + "/sub2")
	self.watcher.Creation(goProject + "/sub")

	self.watcher.Deletion(goProject + "/sub")

	actual = self.watched()
	expected = []*contract.Package{&contract.Package{Active: true, Path: goProject + "/sub2", Name: goPackagePrefix + "/sub2", Result: contract.NewPackageResult(goPackagePrefix + "/sub2")}}
	return
}
コード例 #13
0
ファイル: watcher_test.go プロジェクト: himanshugpt/evergreen
func (self *watcherFixture) ignoreWatchedFolder() (actual, expected interface{}) {
	self.watcher.Creation(goProject + normalize("/sub2"))

	self.watcher.Ignore(goPackagePrefix + normalize("/sub2"))

	actual = self.watched()
	expected = []*contract.Package{&contract.Package{Active: false, Path: goProject + normalize("/sub2"), Name: goPackagePrefix + normalize("/sub2"), Result: contract.NewPackageResult(goPackagePrefix + normalize("/sub2"))}}
	return
}