github.com/kaleido-io/firefly@v0.0.0-20210622132723-8b4b6aacb971/internal/orchestrator/persistence_events_test.go (about)

     1  // Copyright © 2021 Kaleido, Inc.
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //     http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  
    17  package orchestrator
    18  
    19  import (
    20  	"testing"
    21  
    22  	"github.com/kaleido-io/firefly/mocks/batchmocks"
    23  	"github.com/kaleido-io/firefly/mocks/eventmocks"
    24  	"github.com/kaleido-io/firefly/pkg/fftypes"
    25  )
    26  
    27  func TestMessageCreated(t *testing.T) {
    28  	mb := &batchmocks.Manager{}
    29  	o := &orchestrator{
    30  		batch: mb,
    31  	}
    32  	c := make(chan int64, 1)
    33  	mb.On("NewMessages").Return((chan<- int64)(c))
    34  	o.MessageCreated(12345)
    35  	mb.AssertExpectations(t)
    36  }
    37  
    38  func TestPinCreated(t *testing.T) {
    39  	mem := &eventmocks.EventManager{}
    40  	o := &orchestrator{
    41  		events: mem,
    42  	}
    43  	c := make(chan int64, 1)
    44  	mem.On("NewPins").Return((chan<- int64)(c))
    45  	o.PinCreated(12345)
    46  	mem.AssertExpectations(t)
    47  }
    48  
    49  func TestEventCreated(t *testing.T) {
    50  	mem := &eventmocks.EventManager{}
    51  	o := &orchestrator{
    52  		events: mem,
    53  	}
    54  	c := make(chan int64, 1)
    55  	mem.On("NewEvents").Return((chan<- int64)(c))
    56  	o.EventCreated(12345)
    57  	mem.AssertExpectations(t)
    58  }
    59  
    60  func TestSubscriptionCreated(t *testing.T) {
    61  	mem := &eventmocks.EventManager{}
    62  	o := &orchestrator{
    63  		events: mem,
    64  	}
    65  	c := make(chan *fftypes.UUID, 1)
    66  	mem.On("NewSubscriptions").Return((chan<- *fftypes.UUID)(c))
    67  	o.SubscriptionCreated(fftypes.NewUUID())
    68  	mem.AssertExpectations(t)
    69  }
    70  
    71  func TestSubscriptionDeleted(t *testing.T) {
    72  	mem := &eventmocks.EventManager{}
    73  	o := &orchestrator{
    74  		events: mem,
    75  	}
    76  	c := make(chan *fftypes.UUID, 1)
    77  	mem.On("DeletedSubscriptions").Return((chan<- *fftypes.UUID)(c))
    78  	o.SubscriptionDeleted(fftypes.NewUUID())
    79  	mem.AssertExpectations(t)
    80  }