~juju-qa/ubuntu/yakkety/juju/2.0-rc3-again

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/testing/git.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-04-24 22:34:47 UTC
  • Revision ID: package-import@ubuntu.com-20130424223447-f0qdji7ubnyo0s71
Tags: upstream-1.10.0.1
ImportĀ upstreamĀ versionĀ 1.10.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package testing
 
2
 
 
3
import (
 
4
        . "launchpad.net/gocheck"
 
5
        "os"
 
6
)
 
7
 
 
8
type GitSuite struct {
 
9
        oldValues map[string]string
 
10
}
 
11
 
 
12
// We ensure that Git is told about the user name and email if the setup under which the
 
13
// tests are run does not already provide that information. These git env variables are used for
 
14
// that purpose.
 
15
var gitEnvVars = []string{
 
16
        "GIT_AUTHOR_NAME",
 
17
        "GIT_AUTHOR_EMAIL",
 
18
        "GIT_COMMITTER_NAME",
 
19
        "GIT_COMMITTER_EMAIL",
 
20
}
 
21
 
 
22
func (t *GitSuite) SetUpTest(c *C) {
 
23
        t.oldValues = make(map[string]string)
 
24
        for _, v := range gitEnvVars {
 
25
                t.oldValues[v] = os.Getenv(v)
 
26
        }
 
27
        if t.oldValues["GIT_AUTHOR_NAME"] == "" {
 
28
                os.Setenv("GIT_AUTHOR_NAME", "Foo Bar")
 
29
        }
 
30
        if t.oldValues["GIT_AUTHOR_EMAIL"] == "" {
 
31
                os.Setenv("GIT_AUTHOR_EMAIL", "foo@example.org")
 
32
        }
 
33
        os.Setenv("GIT_COMMITTER_NAME", "$GIT_AUTHOR_NAME")
 
34
        os.Setenv("GIT_COMMITTER_EMAIL", "$GIT_AUTHOR_EMAIL")
 
35
}
 
36
 
 
37
func (t *GitSuite) TearDownTest(c *C) {
 
38
        for k, v := range t.oldValues {
 
39
                os.Setenv(k, v)
 
40
        }
 
41
}