github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/upgrade_cluster/send_notification_test.go (about)

     1  package upgrade_cluster
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/kyma-project/kyma-environment-broker/internal"
     8  	"github.com/kyma-project/kyma-environment-broker/internal/logger"
     9  	"github.com/kyma-project/kyma-environment-broker/internal/notification"
    10  	"github.com/kyma-project/kyma-environment-broker/internal/notification/mocks"
    11  	"github.com/kyma-project/kyma-environment-broker/internal/storage"
    12  
    13  	"github.com/stretchr/testify/assert"
    14  )
    15  
    16  func TestSendNotificationStep_Run(t *testing.T) {
    17  	// given
    18  	memoryStorage := storage.NewMemoryStorage()
    19  	tenants := []notification.NotificationTenant{
    20  		{
    21  			InstanceID: notification.FakeInstanceID,
    22  			StartDate:  time.Now().Format("2006-01-02 15:04:05"),
    23  			State:      notification.UnderMaintenanceEventState,
    24  		},
    25  	}
    26  	paras := notification.NotificationParams{
    27  		OrchestrationID: notification.FakeOrchestrationID,
    28  		Tenants:         tenants,
    29  	}
    30  
    31  	bundleBuilder := &mocks.BundleBuilder{}
    32  	bundle := &mocks.Bundle{}
    33  	bundleBuilder.On("NewBundle", notification.FakeOrchestrationID, paras).Return(bundle, nil).Once()
    34  	bundle.On("UpdateNotificationEvent").Return(nil).Once()
    35  
    36  	operation := internal.UpgradeClusterOperation{
    37  		Operation: internal.Operation{
    38  			InstanceID:      notification.FakeInstanceID,
    39  			OrchestrationID: notification.FakeOrchestrationID,
    40  		},
    41  	}
    42  	step := NewSendNotificationStep(memoryStorage.Operations(), bundleBuilder)
    43  
    44  	// when
    45  	_, repeat, err := step.Run(operation, logger.NewLogDummy())
    46  
    47  	// then
    48  	assert.NoError(t, err)
    49  	assert.Equal(t, time.Duration(0), repeat)
    50  }