1
0
Fork 0
mirror of https://github.com/Luzifer/go_helpers.git synced 2024-12-25 21:41:20 +00:00
go_helpers/env/env_test.go

49 lines
853 B
Go
Raw Normal View History

2016-05-28 23:56:12 +00:00
package env_test
import (
"sort"
"testing"
2016-05-28 23:56:12 +00:00
. "github.com/Luzifer/go_helpers/v2/env"
"github.com/stretchr/testify/assert"
2016-05-28 23:56:12 +00:00
)
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": "",
}
)
2016-05-28 23:56:12 +00:00
assert.Equal(t, emap, ListToMap(list))
}
2016-05-28 23:56:12 +00:00
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": "",
}
)
2016-05-28 23:56:12 +00:00
l := MapToList(emap)
sort.Strings(l) // Workaround: The test needs the elements to be in same order
assert.Equal(t, list, l)
}