2024-02-08 03:48:59 -06:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-05-02 10:33:06 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2019-02-25 15:32:47 -06:00
|
|
|
package jsonprovider
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
|
2023-09-20 06:35:35 -05:00
|
|
|
"github.com/opentofu/opentofu/internal/providers"
|
2019-02-25 15:32:47 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMarshalSchemas(t *testing.T) {
|
|
|
|
tests := []struct {
|
2023-07-05 17:06:07 -05:00
|
|
|
Input map[string]providers.Schema
|
|
|
|
Want map[string]*Schema
|
2019-02-25 15:32:47 -06:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
nil,
|
2023-01-09 03:48:23 -06:00
|
|
|
map[string]*Schema{},
|
2019-02-25 15:32:47 -06:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
2023-07-05 17:06:07 -05:00
|
|
|
got := marshalSchemas(test.Input)
|
2019-02-25 15:32:47 -06:00
|
|
|
if !cmp.Equal(got, test.Want) {
|
|
|
|
t.Fatalf("wrong result:\n %v\n", cmp.Diff(got, test.Want))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMarshalSchema(t *testing.T) {
|
|
|
|
tests := map[string]struct {
|
2023-07-05 17:06:07 -05:00
|
|
|
Input providers.Schema
|
2023-01-09 03:48:23 -06:00
|
|
|
Want *Schema
|
2019-02-25 15:32:47 -06:00
|
|
|
}{
|
|
|
|
"nil_block": {
|
2023-07-05 17:06:07 -05:00
|
|
|
providers.Schema{},
|
2023-01-09 03:48:23 -06:00
|
|
|
&Schema{},
|
2019-02-25 15:32:47 -06:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
got := marshalSchema(test.Input)
|
|
|
|
if !cmp.Equal(got, test.Want) {
|
|
|
|
t.Fatalf("wrong result:\n %v\n", cmp.Diff(got, test.Want))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|