airshipctl/pkg/util/tabwriter_test.go
Yasin, Siraj (SY495P) f12446afdf Increase test coverage
Added test cases:
	WriteFiles
	TabWriter
	NewRedfishRemoteDirectClient

Updated:
	ReadYAMLFile	=> new test case with invalid yaml file

Change-Id: I06c6f2eefd1c1c1659e0bf3c08fbe28628c80725
2020-03-17 08:46:34 -05:00

46 lines
703 B
Go

package util_test
import (
"bytes"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"opendev.org/airship/airshipctl/pkg/util"
)
func TestNewTabWriter(t *testing.T) {
var tests = []struct {
testname, src, expected string
}{
{
"empty-string",
"",
"\n",
},
{
"newline-test",
"\n",
"\n\n",
},
{
"format-string",
"airshipctl\tconfig\tinit",
"airshipctl config init\n",
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.testname, func(t *testing.T) {
var buf bytes.Buffer
out := util.NewTabWriter(&buf)
fmt.Fprintln(out, tt.src)
err := out.Flush()
assert.NoError(t, err)
assert.Equal(t, tt.expected, buf.String())
})
}
}