
Added test cases: WriteFiles TabWriter NewRedfishRemoteDirectClient Updated: ReadYAMLFile => new test case with invalid yaml file Change-Id: I06c6f2eefd1c1c1659e0bf3c08fbe28628c80725
29 lines
700 B
Go
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)
|
|
}
|