github.com/argoproj/argo-events@v1.9.1/controllers/eventbus/installer/kafka_test.go (about)

     1  package installer
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     9  
    10  	"github.com/argoproj/argo-events/common/logging"
    11  	"github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1"
    12  )
    13  
    14  const (
    15  	testKafkaName = "test-kafka"
    16  	testKafkaURL  = "kafka:9092"
    17  )
    18  
    19  var (
    20  	testKafkaExoticBus = &v1alpha1.EventBus{
    21  		TypeMeta: metav1.TypeMeta{
    22  			APIVersion: v1alpha1.SchemeGroupVersion.String(),
    23  			Kind:       "EventBus",
    24  		},
    25  		ObjectMeta: metav1.ObjectMeta{
    26  			Namespace: testNamespace,
    27  			Name:      testKafkaName,
    28  		},
    29  		Spec: v1alpha1.EventBusSpec{
    30  			Kafka: &v1alpha1.KafkaBus{
    31  				URL: testKafkaURL,
    32  			},
    33  		},
    34  	}
    35  )
    36  
    37  func TestInstallationKafkaExotic(t *testing.T) {
    38  	t.Run("installation with exotic kafka config", func(t *testing.T) {
    39  		installer := NewExoticKafkaInstaller(testKafkaExoticBus, logging.NewArgoEventsLogger())
    40  		conf, err := installer.Install(context.TODO())
    41  		assert.NoError(t, err)
    42  		assert.NotNil(t, conf.Kafka)
    43  		assert.Equal(t, conf.Kafka.URL, testKafkaURL)
    44  	})
    45  }
    46  
    47  func TestUninstallationKafkaExotic(t *testing.T) {
    48  	t.Run("uninstallation with exotic kafka config", func(t *testing.T) {
    49  		installer := NewExoticKafkaInstaller(testKafkaExoticBus, logging.NewArgoEventsLogger())
    50  		err := installer.Uninstall(context.TODO())
    51  		assert.NoError(t, err)
    52  	})
    53  }