Fritzdect: fix double-quoting of ain
Some checks failed
Some checks failed
This commit is contained in:
parent
fad0288ff7
commit
560ba89734
4 changed files with 8 additions and 10 deletions
|
|
@ -26,5 +26,5 @@ render: |
|
|||
uri: {{ .uri }}
|
||||
user: {{ .user }}
|
||||
password: {{ .password }}
|
||||
ain: "{{ .ain }}" # switch actor identification number without blanks (see AIN number on switch sticker)
|
||||
ain: {{ .ain }} # switch actor identification number without blanks (see AIN number on switch sticker)
|
||||
standbypower: {{ .standbypower }}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ render: |
|
|||
uri: {{ .uri }}
|
||||
user: {{ .user }}
|
||||
password: {{ .password }}
|
||||
ain: "{{ .ain }}" # switch actor identification number without blanks (see AIN number on switch sticker)
|
||||
ain: {{ .ain }} # switch actor identification number without blanks (see AIN number on switch sticker)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ func quote(value string) string {
|
|||
return fmt.Sprintf("'%s'", quoted)
|
||||
}
|
||||
|
||||
// yamlQuote quotes strings for yaml if they would otherwise by modified by the unmarshaler
|
||||
func yamlQuote(value string) string {
|
||||
input := fmt.Sprintf("key: %s", value)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestYamlDecode(t *testing.T) {
|
||||
for _, value := range []string{`value`, `!value`, `@value`, `"value"`, `"va"lue"`, `va'lue`, `@va'lue`, `0815`, `4711`, `#pwd`, ``} {
|
||||
for _, value := range []string{`value`, `!value`, `@value`, `"value"`, `"va"lue"`, `va'lue`, `@va'lue`, `0815`, `"0815"`, `4711`, `#pwd`, ``} {
|
||||
t.Run(value, func(t *testing.T) {
|
||||
quoted := yamlQuote(value)
|
||||
input := fmt.Sprintf("key: %s", quoted)
|
||||
|
|
@ -17,13 +18,9 @@ func TestYamlDecode(t *testing.T) {
|
|||
Value string `yaml:"key"`
|
||||
}
|
||||
|
||||
if err := yaml.Unmarshal([]byte(input), &res); err != nil {
|
||||
t.Fatalf("expected %s (quoted: %s), got error %v", value, quoted, err)
|
||||
}
|
||||
|
||||
if value != res.Value {
|
||||
t.Fatalf("expected %s (quoted: %s), got %s", value, quoted, res.Value)
|
||||
}
|
||||
err := yaml.Unmarshal([]byte(input), &res)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, value, res.Value)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue