11package exercises
22
33import (
4- "sync"
54 "strings"
5+ "sync"
66 "testing"
77 "testing/fstest"
88
@@ -15,7 +15,6 @@ func y(v any) []byte {
1515 return b
1616}
1717
18- //
1918func TestLoadExercisesDir_LoadsValidYAML (t * testing.T ) {
2019 fsys := fstest.MapFS {
2120 "Catalog/Concepts/a.yaml" : & fstest.MapFile {
@@ -55,7 +54,6 @@ func TestLoadExercisesDir_LoadsValidYAML(t *testing.T) {
5554 }
5655}
5756
58-
5957func TestLoadExercisesDir_RejectsEmptySlug (t * testing.T ) {
6058 fsys := fstest.MapFS {
6159 "Catalog/Concepts/bad.yaml" : & fstest.MapFile {
@@ -84,7 +82,6 @@ func TestLoadExercisesDir_IgnoresNonYAML(t *testing.T) {
8482 }
8583}
8684
87-
8885func TestLoadCatalogFromFS_LoadsConceptsAndProjects (t * testing.T ) {
8986 fsys := fstest.MapFS {
9087 "Catalog/Concepts/a.yaml" : & fstest.MapFile {
@@ -148,7 +145,6 @@ func TestLoadCatalogFromFS_InvalidYAML(t *testing.T) {
148145 }
149146}
150147
151-
152148func TestFallbackCatalog (t * testing.T ) {
153149 f := fallbackCatalog ()
154150 if len (f .Concepts ) != 1 {
@@ -159,29 +155,26 @@ func TestFallbackCatalog(t *testing.T) {
159155 }
160156}
161157
162-
163158func TestCatalog_UsesDirectoryLoader (t * testing.T ) {
164- // Reset catalogOnce
165- catalogOnce = sync.Once {}
166-
167- fsys := fstest.MapFS {
168- "Catalog/Concepts/a.yaml" : & fstest.MapFile {
169- Data : y (Exercise {Slug : "01_test" }),
170- },
171- }
172-
173- // Call loader directly
174- cat , err := loadCatalogFromFS (fsys )
175- if err != nil {
176- t .Fatalf ("unexpected error: %v" , err )
177- }
178-
179- if len (cat .Concepts ) != 1 || cat .Concepts [0 ].Slug != "01_test" {
180- t .Fatalf ("loadCatalogFromFS did not correctly read from FS" )
181- }
182- }
159+ // Reset catalogOnce
160+ catalogOnce = sync.Once {}
161+
162+ fsys := fstest.MapFS {
163+ "Catalog/Concepts/a.yaml" : & fstest.MapFile {
164+ Data : y (Exercise {Slug : "01_test" }),
165+ },
166+ }
183167
168+ // Call loader directly
169+ cat , err := loadCatalogFromFS (fsys )
170+ if err != nil {
171+ t .Fatalf ("unexpected error: %v" , err )
172+ }
184173
174+ if len (cat .Concepts ) != 1 || cat .Concepts [0 ].Slug != "01_test" {
175+ t .Fatalf ("loadCatalogFromFS did not correctly read from FS" )
176+ }
177+ }
185178
186179func TestDiscoverLocal_NoDir (t * testing.T ) {
187180 _ , err := discoverLocal ()
0 commit comments