1
0
Fork 0
mirror of https://github.com/Luzifer/go_helpers.git synced 2024-12-25 05:21:20 +00:00
go_helpers/env/env_test.go
Knut Ahlers 82b334b3d3
Fix: Do not panic on weird env list entries
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2021-03-09 23:25:57 +01:00

55 lines
1 KiB
Go

package env_test
import (
"sort"
. "github.com/Luzifer/go_helpers/v2/env"
. "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=",
"NOVALUE",
"",
}
emap = map[string]string{
"FIRST_KEY": "firstvalue",
"SECOND_KEY": "secondvalue",
"WEIRD": "",
"NOVALUE": "",
}
)
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))
})
})
})