get.porter.sh/porter@v1.3.0/pkg/runtime/actionInput_test.go (about)

     1  package runtime
     2  
     3  import (
     4  	"testing"
     5  
     6  	"get.porter.sh/porter/pkg/cnab"
     7  	"get.porter.sh/porter/pkg/manifest"
     8  	"get.porter.sh/porter/pkg/yaml"
     9  	"github.com/stretchr/testify/assert"
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestActionInput_MarshalYAML(t *testing.T) {
    14  	s := &manifest.Step{
    15  		Data: map[string]interface{}{
    16  			"exec": map[string]interface{}{
    17  				"command": "echo hi",
    18  			},
    19  		},
    20  	}
    21  
    22  	input := &ActionInput{
    23  		action: cnab.ActionInstall,
    24  		Steps:  []*manifest.Step{s},
    25  	}
    26  
    27  	b, err := yaml.Marshal(input)
    28  	require.NoError(t, err)
    29  	wantYaml := `install:
    30    - exec:
    31        command: echo hi
    32  `
    33  	assert.Equal(t, wantYaml, string(b))
    34  }