open-nomad/jobspec/utils_test.go
Michael Schurter 17fd82d6ad consul: add Connect structs
Refactor all Consul structs into {api,structs}/services.go because
api/tasks.go didn't make sense anymore and structs/structs.go is
gigantic.
2019-08-06 08:15:07 -07:00

42 lines
622 B
Go

package jobspec
import (
"testing"
"github.com/stretchr/testify/require"
)
// TestFlattenMapSlice asserts flattenMapSlice recursively flattens a slice of maps into a
// single map.
func TestFlattenMapSlice(t *testing.T) {
t.Parallel()
input := map[string]interface{}{
"foo": 123,
"bar": []map[string]interface{}{
{
"baz": 456,
},
{
"baz": 789,
},
{
"baax": true,
},
},
"nil": nil,
}
output := map[string]interface{}{
"foo": 123,
"bar": map[string]interface{}{
"baz": 789,
"baax": true,
},
"nil": nil,
}
require.Equal(t, output, flattenMapSlice(input))
}