diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-06-05 11:42:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-05 11:42:42 +0200 |
commit | 96a108e35075afd13e81df9ba2bf96c8c6125283 (patch) | |
tree | bad8ba6004f59497b00dd4edf098766a375f7beb /config | |
parent | 8019144b6534ff58ad234a355e5b143f1c99b45e (diff) | |
parent | 531a81eae684d8cae617d3d9a26923a66eb25d40 (diff) | |
download | go-git-96a108e35075afd13e81df9ba2bf96c8c6125283.tar.gz |
Merge pull request #84 from go-git/tag-author
CreateTagOptions.Validate: load Tagger from config
Diffstat (limited to 'config')
-rw-r--r-- | config/config_test.go | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/config/config_test.go b/config/config_test.go index e68626b..5a88c19 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,6 +1,10 @@ package config import ( + "io/ioutil" + "os" + "path/filepath" + "github.com/go-git/go-git/v5/plumbing" . "gopkg.in/check.v1" ) @@ -172,8 +176,39 @@ func (s *ConfigSuite) TestUnmarshalMarshal(c *C) { func (s *ConfigSuite) TestLoadConfig(c *C) { cfg, err := LoadConfig(GlobalScope) - c.Assert(err, IsNil) c.Assert(cfg.User.Email, Not(Equals), "") + c.Assert(err, IsNil) + +} + +func (s *ConfigSuite) TestLoadConfigXDG(c *C) { + cfg := NewConfig() + cfg.User.Name = "foo" + cfg.User.Email = "foo@foo.com" + + tmp, err := ioutil.TempDir("", "test-commit-options") + c.Assert(err, IsNil) + defer os.RemoveAll(tmp) + + err = os.Mkdir(filepath.Join(tmp, "git"), 0777) + c.Assert(err, IsNil) + + os.Setenv("XDG_CONFIG_HOME", tmp) + defer func() { + os.Setenv("XDG_CONFIG_HOME", "") + }() + + content, err := cfg.Marshal() + c.Assert(err, IsNil) + + cfgFile := filepath.Join(tmp, "git/config") + err = ioutil.WriteFile(cfgFile, content, 0777) + c.Assert(err, IsNil) + + cfg, err = LoadConfig(GlobalScope) + c.Assert(err, IsNil) + + c.Assert(cfg.User.Email, Equals, "foo@foo.com") } func (s *ConfigSuite) TestValidateConfig(c *C) { |