"Fossies" - the Fresh Open Source Software Archive

Member "istio-1.6.5/galley/pkg/config/testing/fixtures/accumulator_test.go" (8 Jul 2020, 1564 Bytes) of package /linux/misc/istio-1.6.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2019 Istio Authors
    2 //
    3 // Licensed under the Apache License, Version 2.0 (the "License");
    4 // you may not use this file except in compliance with the License.
    5 // You may obtain a copy of the License at
    6 //
    7 //     http://www.apache.org/licenses/LICENSE-2.0
    8 //
    9 // Unless required by applicable law or agreed to in writing, software
   10 // distributed under the License is distributed on an "AS IS" BASIS,
   11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12 // See the License for the specific language governing permissions and
   13 // limitations under the License.
   14 
   15 package fixtures
   16 
   17 import (
   18     "testing"
   19 
   20     "github.com/onsi/gomega"
   21 
   22     "istio.io/istio/galley/pkg/config/testing/data"
   23     "istio.io/istio/pkg/config/event"
   24 )
   25 
   26 func TestAccumulator(t *testing.T) {
   27     g := gomega.NewGomegaWithT(t)
   28 
   29     a := &Accumulator{}
   30 
   31     a.Handle(data.Event1Col1AddItem1)
   32 
   33     expected := []event.Event{data.Event1Col1AddItem1}
   34     g.Expect(a.Events()).To(gomega.Equal(expected))
   35 
   36     a.Handle(data.Event2Col1AddItem2)
   37 
   38     expected = []event.Event{data.Event1Col1AddItem1, data.Event2Col1AddItem2}
   39     g.Expect(a.Events()).To(gomega.Equal(expected))
   40 }
   41 
   42 func TestAccumulator_Clear(t *testing.T) {
   43     g := gomega.NewGomegaWithT(t)
   44 
   45     a := &Accumulator{}
   46 
   47     a.Handle(data.Event1Col1AddItem1)
   48     a.Handle(data.Event2Col1AddItem2)
   49     a.Clear()
   50 
   51     g.Expect(a.Events()).To(gomega.Equal([]event.Event{}))
   52 }
   53 
   54 func TestAccumulator_String(t *testing.T) {
   55     a := &Accumulator{}
   56 
   57     a.Handle(data.Event1Col1AddItem1)
   58     a.Handle(data.Event2Col1AddItem2)
   59 
   60     // ensure that it does not crash
   61     _ = a.String()
   62 }