2016-05-28 23:56:12 +00:00
|
|
|
package env_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sort"
|
|
|
|
|
2021-02-06 21:39:17 +00:00
|
|
|
. "github.com/Luzifer/go_helpers/v2/env"
|
2016-05-28 23:56:12 +00:00
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Env", func() {
|
|
|
|
Context("ListToMap", func() {
|
|
|
|
var (
|
|
|
|
list = []string{
|
|
|
|
"FIRST_KEY=firstvalue",
|
|
|
|
"SECOND_KEY=secondvalue",
|
|
|
|
"WEIRD=",
|
2021-03-09 22:25:57 +00:00
|
|
|
"NOVALUE",
|
2016-05-28 23:56:12 +00:00
|
|
|
"",
|
|
|
|
}
|
|
|
|
emap = map[string]string{
|
|
|
|
"FIRST_KEY": "firstvalue",
|
|
|
|
"SECOND_KEY": "secondvalue",
|
|
|
|
"WEIRD": "",
|
2021-03-09 22:25:57 +00:00
|
|
|
"NOVALUE": "",
|
2016-05-28 23:56:12 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
It("should convert the list in the expected way", func() {
|
|
|
|
Expect(ListToMap(list)).To(Equal(emap))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Context("MapToList", func() {
|
|
|
|
var (
|
|
|
|
list = []string{
|
|
|
|
"FIRST_KEY=firstvalue",
|
|
|
|
"SECOND_KEY=secondvalue",
|
|
|
|
"WEIRD=",
|
|
|
|
}
|
|
|
|
emap = map[string]string{
|
|
|
|
"FIRST_KEY": "firstvalue",
|
|
|
|
"SECOND_KEY": "secondvalue",
|
|
|
|
"WEIRD": "",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
It("should convert the map in the expected way", func() {
|
|
|
|
l := MapToList(emap)
|
|
|
|
sort.Strings(l) // Workaround: The test needs the elements to be in same order
|
|
|
|
Expect(l).To(Equal(list))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|