mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 01:15:43 +03:00
This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
46 lines
727 B
Go
46 lines
727 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package jobspec
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestFlattenMapSlice asserts flattenMapSlice recursively flattens a slice of maps into a
|
|
// single map.
|
|
func TestFlattenMapSlice(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
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))
|
|
|
|
}
|