mirror of https://github.com/pulumi/pulumi.git
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package workspace
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
func TestProjectRuntimeInfoRoundtripYAML(t *testing.T) {
|
|
doTest := func(marshal func(interface{}) ([]byte, error), unmarshal func([]byte, interface{}) error) {
|
|
ri := NewProjectRuntimeInfo("nodejs", nil)
|
|
byts, err := marshal(ri)
|
|
assert.NoError(t, err)
|
|
|
|
var riRountrip ProjectRuntimeInfo
|
|
err = unmarshal(byts, &riRountrip)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "nodejs", riRountrip.Name())
|
|
assert.Nil(t, riRountrip.Options())
|
|
|
|
ri = NewProjectRuntimeInfo("nodejs", map[string]interface{}{
|
|
"typescript": true,
|
|
"stringOption": "hello",
|
|
})
|
|
byts, err = marshal(ri)
|
|
assert.NoError(t, err)
|
|
err = unmarshal(byts, &riRountrip)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "nodejs", riRountrip.Name())
|
|
assert.Equal(t, true, riRountrip.Options()["typescript"])
|
|
assert.Equal(t, "hello", riRountrip.Options()["stringOption"])
|
|
}
|
|
|
|
doTest(yaml.Marshal, yaml.Unmarshal)
|
|
doTest(json.Marshal, json.Unmarshal)
|
|
}
|