|
@ -23,14 +23,18 @@ const aGithubUsername = "a-github-user" |
|
|
const aGithubToken = "a-github-token" |
|
|
const aGithubToken = "a-github-token" |
|
|
|
|
|
|
|
|
var _ = Describe("Read", func() { |
|
|
var _ = Describe("Read", func() { |
|
|
|
|
|
|
|
|
|
|
|
var reader *config.Reader |
|
|
|
|
|
|
|
|
BeforeEach(func() { |
|
|
BeforeEach(func() { |
|
|
os.Clearenv() |
|
|
os.Clearenv() |
|
|
|
|
|
reader = config.NewReader() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
It("parses valid configuration", func() { |
|
|
It("parses valid configuration", func() { |
|
|
aValidEnv() |
|
|
aValidEnv() |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(c).ToNot(BeNil()) |
|
|
Expect(c).ToNot(BeNil()) |
|
|
}) |
|
|
}) |
|
@ -41,7 +45,7 @@ var _ = Describe("Read", func() { |
|
|
setEnv(githubUsername, aGithubUsername) |
|
|
setEnv(githubUsername, aGithubUsername) |
|
|
unsetEnv(githubToken) |
|
|
unsetEnv(githubToken) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(c.Github.Username).To(Equal(aGithubUsername)) |
|
|
Expect(c.Github.Username).To(Equal(aGithubUsername)) |
|
@ -53,7 +57,7 @@ var _ = Describe("Read", func() { |
|
|
setEnv(githubUsername, aGithubUsername) |
|
|
setEnv(githubUsername, aGithubUsername) |
|
|
setEnv(githubToken, aGithubToken) |
|
|
setEnv(githubToken, aGithubToken) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(c.Github.Username).To(Equal(aGithubUsername)) |
|
|
Expect(c.Github.Username).To(Equal(aGithubUsername)) |
|
@ -64,7 +68,7 @@ var _ = Describe("Read", func() { |
|
|
aValidEnv() |
|
|
aValidEnv() |
|
|
unsetEnv(githubUsername) |
|
|
unsetEnv(githubUsername) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(c).To(BeNil()) |
|
|
Expect(c).To(BeNil()) |
|
@ -78,7 +82,7 @@ var _ = Describe("Read", func() { |
|
|
setEnv(giteaUrl, "https://gitea.url/api") |
|
|
setEnv(giteaUrl, "https://gitea.url/api") |
|
|
setEnv(giteaToken, "a-gitea-token") |
|
|
setEnv(giteaToken, "a-gitea-token") |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(c.Gitea.Url).To(Equal("https://gitea.url/api")) |
|
|
Expect(c.Gitea.Url).To(Equal("https://gitea.url/api")) |
|
@ -89,7 +93,7 @@ var _ = Describe("Read", func() { |
|
|
aValidEnv() |
|
|
aValidEnv() |
|
|
unsetEnv(giteaUrl) |
|
|
unsetEnv(giteaUrl) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(c).To(BeNil()) |
|
|
Expect(c).To(BeNil()) |
|
@ -100,7 +104,7 @@ var _ = Describe("Read", func() { |
|
|
aValidEnv() |
|
|
aValidEnv() |
|
|
unsetEnv(giteaToken) |
|
|
unsetEnv(giteaToken) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(c).To(BeNil()) |
|
|
Expect(c).To(BeNil()) |
|
@ -114,7 +118,7 @@ var _ = Describe("Read", func() { |
|
|
aValidEnv() |
|
|
aValidEnv() |
|
|
unsetEnv(mirrorMode) |
|
|
unsetEnv(mirrorMode) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(c.MirrorMode).To(Equal(config.MirrorModePublic)) |
|
|
Expect(c.MirrorMode).To(Equal(config.MirrorModePublic)) |
|
@ -124,7 +128,7 @@ var _ = Describe("Read", func() { |
|
|
aValidEnv() |
|
|
aValidEnv() |
|
|
setEnv(mirrorMode, in) |
|
|
setEnv(mirrorMode, in) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(err).NotTo(HaveOccurred()) |
|
|
Expect(c.MirrorMode).To(Equal(exp)) |
|
|
Expect(c.MirrorMode).To(Equal(exp)) |
|
@ -137,7 +141,7 @@ var _ = Describe("Read", func() { |
|
|
aValidEnv() |
|
|
aValidEnv() |
|
|
setEnv(mirrorMode, unknownMirrorMode) |
|
|
setEnv(mirrorMode, unknownMirrorMode) |
|
|
|
|
|
|
|
|
c, err := config.Read() |
|
|
|
|
|
|
|
|
c, err := reader.Read() |
|
|
|
|
|
|
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(err).To(HaveOccurred()) |
|
|
Expect(c).To(BeNil()) |
|
|
Expect(c).To(BeNil()) |
|
|