airshipctl/pkg/util/configreader_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

29 lines
700 B
Go

package util_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"opendev.org/airship/airshipctl/pkg/util"
)
func TestReadYAMLFile(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
var actual map[string]interface{}
err := util.ReadYAMLFile("testdata/test.yaml", &actual)
require.NoError(err, "Error while reading YAML")
actualString := actual["testString"]
expectedString := "test"
assert.Equal(expectedString, actualString)
// test using an incorrect yaml
err = util.ReadYAMLFile("testdata/incorrect.yaml", &actual)
expectedString = "error converting YAML to JSON"
require.Contains(err.Error(), expectedString)
}