1
0
Fork 0
mirror of https://github.com/Luzifer/go_helpers.git synced 2024-12-25 13:31:21 +00:00
go_helpers/env/env_test.go
Knut Ahlers 63159db627
Remove gomega from tests and update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-10-12 13:39:52 +02:00

48 lines
853 B
Go

package env_test
import (
"sort"
"testing"
. "github.com/Luzifer/go_helpers/v2/env"
"github.com/stretchr/testify/assert"
)
func TestListToMap(t *testing.T) {
var (
list = []string{
"FIRST_KEY=firstvalue",
"SECOND_KEY=secondvalue",
"WEIRD=",
"NOVALUE",
"",
}
emap = map[string]string{
"FIRST_KEY": "firstvalue",
"SECOND_KEY": "secondvalue",
"WEIRD": "",
"NOVALUE": "",
}
)
assert.Equal(t, emap, ListToMap(list))
}
func TestMapToList(t *testing.T) {
var (
list = []string{
"FIRST_KEY=firstvalue",
"SECOND_KEY=secondvalue",
"WEIRD=",
}
emap = map[string]string{
"FIRST_KEY": "firstvalue",
"SECOND_KEY": "secondvalue",
"WEIRD": "",
}
)
l := MapToList(emap)
sort.Strings(l) // Workaround: The test needs the elements to be in same order
assert.Equal(t, list, l)
}