github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/rego/convert/struct_test.go (about)

     1  package convert
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func Test_StructConversion(t *testing.T) {
    11  	input := struct {
    12  		X string
    13  		Y int
    14  		Z struct {
    15  			A float64
    16  		}
    17  	}{}
    18  	input.Z.A = 123
    19  	converted := StructToRego(reflect.ValueOf(input))
    20  	assert.Equal(t, map[string]interface{}{"z": map[string]interface{}{}}, converted)
    21  }