gotest.tools/gotestsum@v1.11.0/cmd/flags_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gotest.tools/v3/assert"
     7  )
     8  
     9  func TestNoSummaryValue_SetAndString(t *testing.T) {
    10  	t.Run("none", func(t *testing.T) {
    11  		assert.Equal(t, newHideSummaryValue().String(), "none")
    12  	})
    13  	t.Run("one", func(t *testing.T) {
    14  		value := newHideSummaryValue()
    15  		assert.NilError(t, value.Set("output"))
    16  		assert.Equal(t, value.String(), "output")
    17  	})
    18  	t.Run("some", func(t *testing.T) {
    19  		value := newHideSummaryValue()
    20  		assert.NilError(t, value.Set("errors,failed"))
    21  		assert.Equal(t, value.String(), "failed,errors")
    22  	})
    23  	t.Run("bad value", func(t *testing.T) {
    24  		value := newHideSummaryValue()
    25  		assert.ErrorContains(t, value.Set("bogus"), "must be one or more of")
    26  	})
    27  }
    28  
    29  func TestStringSlice(t *testing.T) {
    30  	value := "one \ntwo  three\n\tfour\t five   \n"
    31  	var v []string
    32  	ss := (*stringSlice)(&v)
    33  	assert.NilError(t, ss.Set(value))
    34  	assert.DeepEqual(t, v, []string{"one", "two", "three", "four", "five"})
    35  }