aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go
index 35a62f1..51df845 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -75,6 +75,13 @@ func (s *RepositorySuite) TestInitWithOptions(c *C) {
}
+func (s *RepositorySuite) TestInitWithInvalidDefaultBranch(c *C) {
+ _, err := InitWithOptions(memory.NewStorage(), memfs.New(), InitOptions{
+ DefaultBranch: "foo",
+ })
+ c.Assert(err, NotNil)
+}
+
func createCommit(c *C, r *Repository) {
// Create a commit so there is a HEAD to check
wt, err := r.Worktree()
@@ -391,6 +398,22 @@ func (s *RepositorySuite) TestDeleteRemote(c *C) {
c.Assert(alt, IsNil)
}
+func (s *RepositorySuite) TestEmptyCreateBranch(c *C) {
+ r, _ := Init(memory.NewStorage(), nil)
+ err := r.CreateBranch(&config.Branch{})
+
+ c.Assert(err, NotNil)
+}
+
+func (s *RepositorySuite) TestInvalidCreateBranch(c *C) {
+ r, _ := Init(memory.NewStorage(), nil)
+ err := r.CreateBranch(&config.Branch{
+ Name: "-foo",
+ })
+
+ c.Assert(err, NotNil)
+}
+
func (s *RepositorySuite) TestCreateBranchAndBranch(c *C) {
r, _ := Init(memory.NewStorage(), nil)
testBranch := &config.Branch{
@@ -2797,6 +2820,20 @@ func (s *RepositorySuite) TestDeleteTagAnnotatedUnpacked(c *C) {
c.Assert(err, Equals, plumbing.ErrObjectNotFound)
}
+func (s *RepositorySuite) TestInvalidTagName(c *C) {
+ r, err := Init(memory.NewStorage(), nil)
+ c.Assert(err, IsNil)
+ for i, name := range []string{
+ "",
+ "foo bar",
+ "foo\tbar",
+ "foo\nbar",
+ } {
+ _, err = r.CreateTag(name, plumbing.ZeroHash, nil)
+ c.Assert(err, NotNil, Commentf("case %d %q", i, name))
+ }
+}
+
func (s *RepositorySuite) TestBranches(c *C) {
f := fixtures.ByURL("https://github.com/git-fixtures/root-references.git").One()
sto := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())