File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1+ package provider_test
2+
3+ import (
4+ "testing"
5+
6+ "github.com/coder/terraform-provider-coder/provider"
7+ "github.com/mitchellh/mapstructure"
8+ "github.com/stretchr/testify/require"
9+ )
10+
11+ func TestDecode (t * testing.T ) {
12+ const (
13+ legacyVariable = "Legacy Variable"
14+ legacyVariableName = "Legacy Variable Name"
15+ )
16+
17+ aMap := map [string ]interface {}{
18+ "name" : "Parameter Name" ,
19+ "legacy_variable" : legacyVariable ,
20+ "legacy_variable_name" : legacyVariableName ,
21+ }
22+
23+ var param provider.Parameter
24+ err := mapstructure .Decode (aMap , & param )
25+ require .NoError (t , err )
26+ require .Equal (t , legacyVariable , param .LegacyVariable )
27+ require .Equal (t , legacyVariableName , param .LegacyVariableName )
28+ }
Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ type Parameter struct {
5151 Validation []Validation
5252 Optional bool
5353
54- LegacyVariableName string
55- LegacyVariable string
54+ LegacyVariableName string `mapstructure:"legacy_variable_name"`
55+ LegacyVariable string `mapstructure:"legacy_variable"`
5656}
5757
5858func parameterDataSource () * schema.Resource {
You can’t perform that action at this time.
0 commit comments