github.com/vmware/govmomi@v0.51.0/vim25/progress/prefix_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 TestPrefix(t *testing.T) {
    10  	var r Report
    11  
    12  	ch := make(chan Report, 1)
    13  	s := Prefix(dummySinker{ch}, "prefix").Sink()
    14  
    15  	// No detail
    16  	s <- dummyReport{d: ""}
    17  	r = <-ch
    18  	if r.Detail() != "prefix" {
    19  		t.Errorf("Expected detail to be prefixed")
    20  	}
    21  
    22  	// With detail
    23  	s <- dummyReport{d: "something"}
    24  	r = <-ch
    25  	if r.Detail() != "prefix: something" {
    26  		t.Errorf("Expected detail to be prefixed")
    27  	}
    28  }