File: flags_test.go

package info (click to toggle)
gotestsum 1.8.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,060 kB
  • sloc: sh: 89; makefile: 16
file content (35 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package cmd

import (
	"testing"

	"gotest.tools/v3/assert"
)

func TestNoSummaryValue_SetAndString(t *testing.T) {
	t.Run("none", func(t *testing.T) {
		assert.Equal(t, newHideSummaryValue().String(), "none")
	})
	t.Run("one", func(t *testing.T) {
		value := newHideSummaryValue()
		assert.NilError(t, value.Set("output"))
		assert.Equal(t, value.String(), "output")
	})
	t.Run("some", func(t *testing.T) {
		value := newHideSummaryValue()
		assert.NilError(t, value.Set("errors,failed"))
		assert.Equal(t, value.String(), "failed,errors")
	})
	t.Run("bad value", func(t *testing.T) {
		value := newHideSummaryValue()
		assert.ErrorContains(t, value.Set("bogus"), "must be one or more of")
	})
}

func TestStringSlice(t *testing.T) {
	value := "one \ntwo  three\n\tfour\t five   \n"
	var v []string
	ss := (*stringSlice)(&v)
	assert.NilError(t, ss.Set(value))
	assert.DeepEqual(t, v, []string{"one", "two", "three", "four", "five"})
}