mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-15 11:56:37 +02:00
Rename UpdateYaml to UpdateYamlValue
We are going to add other ways to update yaml documents in the future.
This commit is contained in:
parent
bf685cf832
commit
a14794bf5c
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// takes a yaml document in bytes, a path to a key, and a value to set. The value must be a scalar.
|
// takes a yaml document in bytes, a path to a key, and a value to set. The value must be a scalar.
|
||||||
func UpdateYaml(yamlBytes []byte, path []string, value string) ([]byte, error) {
|
func UpdateYamlValue(yamlBytes []byte, path []string, value string) ([]byte, error) {
|
||||||
// Parse the YAML file.
|
// Parse the YAML file.
|
||||||
var node yaml.Node
|
var node yaml.Node
|
||||||
err := yaml.Unmarshal(yamlBytes, &node)
|
err := yaml.Unmarshal(yamlBytes, &node)
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUpdateYaml(t *testing.T) {
|
func TestUpdateYamlValue(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
in string
|
in string
|
||||||
@ -53,7 +53,7 @@ func TestUpdateYaml(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
test := test
|
test := test
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
out, actualErr := UpdateYaml([]byte(test.in), test.path, test.value)
|
out, actualErr := UpdateYamlValue([]byte(test.in), test.path, test.value)
|
||||||
if test.expectedErr == "" {
|
if test.expectedErr == "" {
|
||||||
assert.NoError(t, actualErr)
|
assert.NoError(t, actualErr)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user