1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/utils/conversions_test.go
Chris Cummer 1bfca29d17
WTF-657 Add spec coverage for cfg/common_settings.go (#728)
* WTF-657 Add spec coverage for cfg/common_settings.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Add spec coverage for cfg/position_validation.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Add spec coverage for cfg/validations.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Add spec coverage for checklist/checklist.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Add spec coverage for checklist/checklist_item.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Add spec coverage for utils/conversions.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Get rid of utils.Home() function

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Add spec coverage for utils/homedir.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Add spec coverage for utils/text.go

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-657 Clean up utils/utils.go

Signed-off-by: Chris Cummer <chriscummer@me.com>
2019-10-30 17:35:00 -07:00

52 lines
949 B
Go

package utils
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_MapToStrs(t *testing.T) {
expected := map[string]string{
"a": "a",
"b": "b",
"c": "c",
}
source := make(map[string]interface{})
for _, val := range expected {
source[val] = val
}
assert.Equal(t, expected, MapToStrs(source))
}
func Test_ToInts(t *testing.T) {
expected := []int{1, 2, 3}
source := make([]interface{}, len(expected))
for idx, val := range expected {
source[idx] = val
}
assert.Equal(t, expected, ToInts(source))
}
func Test_ToStrs(t *testing.T) {
expectedInts := []int{1, 2, 3}
expectedStrs := []string{"1", "2", "3"}
fromInts := make([]interface{}, 3)
for idx, val := range expectedInts {
fromInts[idx] = val
}
fromStrs := make([]interface{}, 3)
for idx, val := range expectedStrs {
fromStrs[idx] = val
}
assert.Equal(t, expectedStrs, ToStrs(fromInts))
assert.Equal(t, expectedStrs, ToStrs(fromStrs))
}