mirror of https://github.com/databricks/cli.git
31 lines
683 B
Go
31 lines
683 B
Go
|
package yamlloader_test
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/databricks/cli/libs/config"
|
||
|
"github.com/databricks/cli/libs/config/yamlloader"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"github.com/stretchr/testify/require"
|
||
|
"gopkg.in/yaml.v3"
|
||
|
)
|
||
|
|
||
|
func loadYAML(t *testing.T, path string) config.Value {
|
||
|
input, err := os.ReadFile(path)
|
||
|
require.NoError(t, err)
|
||
|
|
||
|
var ref any
|
||
|
err = yaml.Unmarshal(input, &ref)
|
||
|
require.NoError(t, err)
|
||
|
|
||
|
self, err := yamlloader.LoadYAML(path, bytes.NewBuffer(input))
|
||
|
require.NoError(t, err)
|
||
|
assert.NotNil(t, self)
|
||
|
|
||
|
// Deep-equal the two values to ensure that the loader is producing
|
||
|
assert.EqualValues(t, ref, self.AsAny())
|
||
|
return self
|
||
|
}
|