File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,35 @@ func TestNewRegistry(t *testing.T) {
83
83
}
84
84
}
85
85
86
+ func TestRegistry_Get (t * testing.T ) {
87
+ t .Parallel ()
88
+
89
+ t .Run ("can get templates concurrently" , func (t * testing.T ) {
90
+ fs := fstest.MapFS {
91
+ "custom/template1.html" : & fstest.MapFile {
92
+ Data : []byte (testHTMLTemplate ),
93
+ },
94
+ }
95
+
96
+ opts := []Option [TestData ]{WithTemplatesPath [TestData ]("custom" )}
97
+
98
+ registry , err := NewRegistry (fs , opts ... )
99
+ require .NoError (t , err )
100
+
101
+ var wg sync.WaitGroup
102
+
103
+ wg .Add (2 )
104
+ for i := 0 ; i < 2 ; i ++ {
105
+ go func (wg * sync.WaitGroup ) {
106
+ defer wg .Done ()
107
+ _ , err := registry .Get ("template1" )
108
+ require .NoError (t , err )
109
+ }(& wg )
110
+ }
111
+ wg .Wait ()
112
+ })
113
+ }
114
+
86
115
func TestHandler (t * testing.T ) {
87
116
t .Parallel ()
88
117
@@ -342,7 +371,7 @@ func TestRegistry_Options(t *testing.T) {
342
371
}
343
372
}
344
373
345
- func TestWithFuncs (t * testing.T ) {
374
+ func TestWithTemplateFuncs (t * testing.T ) {
346
375
t .Parallel ()
347
376
348
377
funcMap := template.FuncMap {
You can’t perform that action at this time.
0 commit comments