Skip to content

Commit

Permalink
test: add test for the remote URLs (pull and push)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcepl committed Sep 2, 2024
1 parent f3816b5 commit 7dd2962
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions _examples/push/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func main() {
r, err := git.PlainOpen(path)
CheckIfError(err)

Info("git push")
// push using default options
err = r.Push(&git.PushOptions{})
CheckIfError(err)
Expand Down
24 changes: 24 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,27 @@ func (s *ConfigSuite) TestRemoveUrlOptions(c *C) {
}
c.Assert(err, IsNil)
}

func (s *ConfigSuite) TestUnmarshalRemotes(c *C) {
input := []byte(`[core]
bare = true
worktree = foo
custom = ignored
[user]
name = John Doe
email = [email protected]
[remote "origin"]
url = https://git.sr.ht/~mcepl/go-git
pushurl = [email protected]:~mcepl/go-git.git
fetch = +refs/heads/*:refs/remotes/origin/*
mirror = true
`)

cfg := NewConfig()
err := cfg.Unmarshal(input)
c.Assert(err, IsNil)

c.Assert(cfg.Remotes["origin"].URLs[0], Equals, "https://git.sr.ht/~mcepl/go-git")
c.Assert(cfg.Remotes["origin"].URLs[1], Equals, "[email protected]:~mcepl/go-git.git")
}

0 comments on commit 7dd2962

Please sign in to comment.