github.com/vmware/govmomi@v0.51.0/vim25/progress/tee_test.go (about)

     1  // © Broadcom. All Rights Reserved.
     2  // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package progress
     6  
     7  import "testing"
     8  
     9  func TestTee(t *testing.T) {
    10  	var ok bool
    11  
    12  	ch1 := make(chan Report)
    13  	ch2 := make(chan Report)
    14  
    15  	s := Tee(&dummySinker{ch: ch1}, &dummySinker{ch: ch2})
    16  
    17  	in := s.Sink()
    18  	in <- dummyReport{}
    19  	close(in)
    20  
    21  	// Receive dummy on both sinks
    22  	<-ch1
    23  	<-ch2
    24  
    25  	_, ok = <-ch1
    26  	if ok {
    27  		t.Errorf("Expected channel to be closed")
    28  	}
    29  
    30  	_, ok = <-ch2
    31  	if ok {
    32  		t.Errorf("Expected channel to be closed")
    33  	}
    34  }