github.com/kiali/kiali@v1.84.0/business/checkers/k8sgateways/status_checker_test.go (about) 1 package k8sgateways 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/kiali/kiali/config" 9 "github.com/kiali/kiali/models" 10 "github.com/kiali/kiali/tests/data" 11 ) 12 13 func TestCorrectK8sGatewaysStatus(t *testing.T) { 14 conf := config.NewConfig() 15 config.Set(conf) 16 17 assert := assert.New(t) 18 19 k8sgwObject := data.CreateEmptyK8sGateway("validgateway", "test") 20 21 k8sgws := StatusChecker{k8sgwObject} 22 23 check, isValid := k8sgws.Check() 24 25 assert.True(isValid) 26 assert.Empty(check) 27 } 28 29 func TestIncorrectK8sGatewaysStatus(t *testing.T) { 30 conf := config.NewConfig() 31 config.Set(conf) 32 33 assert := assert.New(t) 34 35 gwAddress := data.CreateGWAddress("IPAddress", "192.168.0.0") 36 k8sgwObject := data.AddListenerToK8sGateway(data.CreateListener("test", "host.com.wrong", 11, "http"), 37 data.CreateEmptyK8sGateway("validk8sgateway", "test")) 38 k8sgwObject = data.AddGwAddressToK8sGateway(gwAddress, k8sgwObject) 39 k8sgwObject = data.UpdateConditionWithError(k8sgwObject) 40 41 k8sgws := StatusChecker{k8sgwObject} 42 43 check, isValid := k8sgws.Check() 44 45 assert.False(isValid) 46 assert.NotEmpty(check) 47 assert.Equal("Fake msg. GWAPI errors should be changed in the spec.", check[0].Message) 48 assert.Equal(models.WarningSeverity, check[0].Severity) 49 }