github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/model/integrationsystem_test.go (about) 1 package model_test 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 9 "github.com/kyma-incubator/compass/components/director/internal/model" 10 ) 11 12 func TestIntegrationSystemInput_ToIntegrationSystem(t *testing.T) { 13 // GIVEN 14 id := "foo" 15 16 testCases := []struct { 17 Name string 18 Input *model.IntegrationSystemInput 19 Expected model.IntegrationSystem 20 }{ 21 { 22 Name: "All properties given", 23 Input: &model.IntegrationSystemInput{ 24 Name: "TestSystem", 25 }, 26 Expected: model.IntegrationSystem{ 27 ID: id, 28 Name: "TestSystem", 29 }, 30 }, 31 { 32 Name: "Empty", 33 Input: &model.IntegrationSystemInput{}, 34 Expected: model.IntegrationSystem{ 35 ID: id, 36 }, 37 }, 38 { 39 Name: "Nil", 40 Input: nil, 41 Expected: model.IntegrationSystem{}, 42 }, 43 } 44 45 for i, testCase := range testCases { 46 t.Run(fmt.Sprintf("%d: %s", i, testCase.Name), func(t *testing.T) { 47 // WHEN 48 result := testCase.Input.ToIntegrationSystem(id) 49 50 // THEN 51 assert.Equal(t, testCase.Expected, result) 52 }) 53 } 54 }