|
11 | 11 | package tests |
12 | 12 |
|
13 | 13 | import ( |
14 | | - "bytes" |
15 | | - "html/template" |
16 | 14 | "maps" |
17 | 15 | "strconv" |
18 | 16 | "strings" |
19 | 17 |
|
20 | | - "github.com/stretchr/testify/require" |
21 | | - |
22 | | - "github.com/sourcenetwork/defradb/errors" |
23 | 18 | "github.com/sourcenetwork/defradb/tests/state" |
24 | 19 | ) |
25 | 20 |
|
@@ -69,31 +64,6 @@ var templateDataGenerators = map[string]func(*state.State, int) map[string]strin |
69 | 64 | }, |
70 | 65 | } |
71 | 66 |
|
72 | | -// replace returns a new string with any templating placholders (see "text/template") with data drawn |
73 | | -// from `state`. |
74 | | -func replace(s *state.State, nodeId int, input string) string { |
75 | | - if !strings.Contains(input, "{{") { |
76 | | - // If the input doesn't contain any templating elements we can return early |
77 | | - return input |
78 | | - } |
79 | | - |
80 | | - templateData := map[string]string{} |
81 | | - for _, datasetGenerator := range templateDataGenerators { |
82 | | - // Having to regenerate the full dataset for every node-action is horribly inefficient, but |
83 | | - // it is tolerable for now. |
84 | | - maps.Copy(templateData, datasetGenerator(s, nodeId)) |
85 | | - } |
86 | | - |
87 | | - tmpl := template.Must(template.New("").Parse(input)) |
88 | | - var buf bytes.Buffer |
89 | | - err := tmpl.Execute(&buf, templateData) |
90 | | - if err != nil { |
91 | | - require.Fail(s.T, errors.WithStack(err).Error()) |
92 | | - } |
93 | | - |
94 | | - return buf.String() |
95 | | -} |
96 | | - |
97 | 67 | func replaceMap(s *state.State, nodeId int, inputSet []string) map[string]string { |
98 | 68 | templateData := map[string]string{} |
99 | 69 | for _, datasetGenerator := range templateDataGenerators { |
|
0 commit comments