Skip to content
Snippets Groups Projects
Commit 583db019 authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge branch 'feature/PRXS-2865-CustomYAMLTags' into 'master'

Добавлены тесты для проверки объединения yaml конфигураций с помощью тега !include

See merge request perxis/perxis-go!338
parents c96547aa 8f3cea54
No related branches found
No related tags found
No related merge requests found
......@@ -31,14 +31,34 @@ func TestTagProcessor(t *testing.T) {
}`}, result)
})
t.Run("!include", func(t *testing.T) {
file, err := testdata.FS.Open("include/include_simple.yaml")
require.NoError(t, err)
defer file.Close()
t.Run("simple", func(t *testing.T) {
file, err := testdata.FS.Open("include/include_simple.yaml")
require.NoError(t, err)
defer file.Close()
var result any
decoder := yaml.NewDecoder(file)
err = decoder.Decode(WithTagProcessor(testdata.FS)(&result))
require.NoError(t, err)
assert.Equal(t, map[string]any{"data": map[string]any{"text": "Hello, World!"}}, result)
var result any
decoder := yaml.NewDecoder(file)
err = decoder.Decode(WithTagProcessor(testdata.FS)(&result))
require.NoError(t, err)
assert.Equal(t, map[string]any{"data": map[string]any{"text": "Hello, World!"}}, result)
})
t.Run("with merge", func(t *testing.T) {
file, err := testdata.FS.Open("include/include_merge.yaml")
require.NoError(t, err)
defer file.Close()
var result any
decoder := yaml.NewDecoder(file)
err = decoder.Decode(WithTagProcessor(testdata.FS)(&result))
require.NoError(t, err)
assert.Equal(t, map[string]any{
"server": map[string]any{
"host": "dev.perx.ru",
"port": 3000,
"ssl": true,
"tags": []any{"http", "api"},
},
}, result)
})
})
}
host: localhost
port: 3000
ssl: true
<<: !include include/default_server_tags.yaml
\ No newline at end of file
tags: [ http, api ]
\ No newline at end of file
server:
<<: !include include/default_server_config.yaml
host: dev.perx.ru
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment