packer-cn/post-processor/yandex-import/artifact_test.go

28 lines
595 B
Go
Raw Normal View History

2020-07-21 18:01:30 -04:00
package yandeximport
import (
"testing"
2020-07-22 04:39:28 -04:00
"github.com/stretchr/testify/require"
2020-07-21 18:01:30 -04:00
)
func TestArtifactState_StateData(t *testing.T) {
expectedData := "this is the data"
artifact := &Artifact{
StateData: map[string]interface{}{"state_data": expectedData},
}
// Valid state
result := artifact.State("state_data")
require.Equal(t, expectedData, result)
// Invalid state
result = artifact.State("invalid_key")
require.Equal(t, nil, result)
// Nil StateData should not fail and should return nil
artifact = &Artifact{}
result = artifact.State("key")
require.Equal(t, nil, result)
}