tests: fixed issue with server not starting with correct config

This commit is contained in:
David Allen 2024-12-10 15:22:37 -07:00
parent 1848819244
commit d2b6178350
Signed by: towk
GPG key ID: 793B2924A49B3A3F

View file

@ -23,6 +23,8 @@ var (
err error err error
) )
const ()
// A valid test generator that implements the `Generator` interface. // A valid test generator that implements the `Generator` interface.
type TestGenerator struct{} type TestGenerator struct{}
@ -33,17 +35,21 @@ func (g *TestGenerator) GetDescription() string {
} }
func (g *TestGenerator) Generate(config *config.Config, params generator.Params) (generator.FileMap, error) { func (g *TestGenerator) Generate(config *config.Config, params generator.Params) (generator.FileMap, error) {
// Jinja 2 template file // Jinja 2 template file
files := [][]byte{ files := map[string]generator.Template{
[]byte(` "test1": generator.Template{
Contents: []byte(`
Name: {{plugin_name}} Name: {{plugin_name}}
Version: {{plugin_version}} Version: {{plugin_version}}
Description: {{plugin_description}} Description: {{plugin_description}}
This is the first test template file. This is the first test template file.
`), `),
[]byte(` },
"test2": generator.Template{
Contents: []byte(`
This is another testing Jinja 2 template file using {{plugin_name}}. This is another testing Jinja 2 template file using {{plugin_name}}.
`), `),
},
} }
// apply Jinja templates to file // apply Jinja templates to file
@ -51,7 +57,7 @@ This is another testing Jinja 2 template file using {{plugin_name}}.
"plugin_name": g.GetName(), "plugin_name": g.GetName(),
"plugin_version": g.GetVersion(), "plugin_version": g.GetVersion(),
"plugin_description": g.GetDescription(), "plugin_description": g.GetDescription(),
}, params.Templates) }, files)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to apply templates: %v", err) return nil, fmt.Errorf("failed to apply templates: %v", err)
} }