github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/command/jsonprovider/schema_test.go (about)

     1  package jsonprovider
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/google/go-cmp/cmp"
     7  
     8  	"github.com/hashicorp/terraform/configs/configschema"
     9  )
    10  
    11  func TestMarshalSchemas(t *testing.T) {
    12  	tests := []struct {
    13  		Input    map[string]*configschema.Block
    14  		Versions map[string]uint64
    15  		Want     map[string]*schema
    16  	}{
    17  		{
    18  			nil,
    19  			map[string]uint64{},
    20  			map[string]*schema{},
    21  		},
    22  	}
    23  
    24  	for _, test := range tests {
    25  		got := marshalSchemas(test.Input, test.Versions)
    26  		if !cmp.Equal(got, test.Want) {
    27  			t.Fatalf("wrong result:\n %v\n", cmp.Diff(got, test.Want))
    28  		}
    29  	}
    30  }
    31  
    32  func TestMarshalSchema(t *testing.T) {
    33  	tests := map[string]struct {
    34  		Input *configschema.Block
    35  		Want  *schema
    36  	}{
    37  		"nil_block": {
    38  			nil,
    39  			&schema{},
    40  		},
    41  	}
    42  
    43  	for _, test := range tests {
    44  		got := marshalSchema(test.Input)
    45  		if !cmp.Equal(got, test.Want) {
    46  			t.Fatalf("wrong result:\n %v\n", cmp.Diff(got, test.Want))
    47  		}
    48  	}
    49  }