Skip to content

Commit

Permalink
fix: annotate multi-words fields (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtojek authored Mar 22, 2023
1 parent dd15752 commit f0da725
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions provider/decode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package provider_test

import (
"testing"

"github.com/coder/terraform-provider-coder/provider"
"github.com/mitchellh/mapstructure"
"github.com/stretchr/testify/require"
)

func TestDecode(t *testing.T) {
const (
legacyVariable = "Legacy Variable"
legacyVariableName = "Legacy Variable Name"
)

aMap := map[string]interface{}{
"name": "Parameter Name",
"legacy_variable": legacyVariable,
"legacy_variable_name": legacyVariableName,
}

var param provider.Parameter
err := mapstructure.Decode(aMap, &param)
require.NoError(t, err)
require.Equal(t, legacyVariable, param.LegacyVariable)
require.Equal(t, legacyVariableName, param.LegacyVariableName)
}
4 changes: 2 additions & 2 deletions provider/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type Parameter struct {
Validation []Validation
Optional bool

LegacyVariableName string
LegacyVariable string
LegacyVariableName string `mapstructure:"legacy_variable_name"`
LegacyVariable string `mapstructure:"legacy_variable"`
}

func parameterDataSource() *schema.Resource {
Expand Down

0 comments on commit f0da725

Please sign in to comment.