github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/formationtemplateconstraintreferences/converter_test.go (about) 1 package formationtemplateconstraintreferences_test 2 3 import ( 4 "testing" 5 6 "github.com/kyma-incubator/compass/components/director/internal/domain/formationtemplateconstraintreferences" 7 "github.com/stretchr/testify/require" 8 ) 9 10 var converter = formationtemplateconstraintreferences.NewConverter() 11 12 func TestToEntity(t *testing.T) { 13 t.Run("Success", func(t *testing.T) { 14 // WHEN 15 actual := converter.ToEntity(constraintReference) 16 17 // THEN 18 require.Equal(t, entity, actual) 19 }) 20 t.Run("Nil input", func(t *testing.T) { 21 // WHEN 22 actual := converter.ToEntity(nil) 23 24 // THEN 25 require.Nil(t, actual) 26 }) 27 } 28 29 func TestFromEntity(t *testing.T) { 30 t.Run("Success", func(t *testing.T) { 31 // WHEN 32 actual := converter.FromEntity(entity) 33 34 // THEN 35 require.Equal(t, constraintReference, actual) 36 }) 37 t.Run("Nil input", func(t *testing.T) { 38 // WHEN 39 actual := converter.FromEntity(nil) 40 41 // THEN 42 require.Nil(t, actual) 43 }) 44 } 45 46 func TestToModel(t *testing.T) { 47 t.Run("Success", func(t *testing.T) { 48 // WHEN 49 actual := converter.ToModel(gqlConstraintReference) 50 51 // THEN 52 require.Equal(t, constraintReference, actual) 53 }) 54 t.Run("Nil input", func(t *testing.T) { 55 // WHEN 56 actual := converter.ToModel(nil) 57 58 // THEN 59 require.Nil(t, actual) 60 }) 61 } 62 63 func TestFromGraphql(t *testing.T) { 64 t.Run("Success", func(t *testing.T) { 65 // WHEN 66 actual := converter.ToGraphql(constraintReference) 67 68 // THEN 69 require.Equal(t, gqlConstraintReference, actual) 70 }) 71 t.Run("Nil input", func(t *testing.T) { 72 // WHEN 73 actual := converter.ToGraphql(nil) 74 75 // THEN 76 require.Nil(t, actual) 77 }) 78 }