[READ-ONLY] Mirror of https://github.com/jphastings/mela-recipes. An opinionated library for stream-parsing Mela's recipe files.
cooking cooking-recipes mela recipes
0

Configure Feed

Select the types of activity you want to include in your feed.

mela-recipes / formats_test.go
1.8 kB 54 lines
1package recipes_test 2 3import ( 4 "testing" 5 6 . "github.com/jphastings/recipes" 7 "github.com/jphastings/recipes/cooklang" 8 "github.com/jphastings/recipes/crouton" 9 "github.com/jphastings/recipes/internal/formats" 10 "github.com/jphastings/recipes/mela" 11 "github.com/stretchr/testify/assert" 12) 13 14func TestParseDestination(t *testing.T) { 15 tc := []struct { 16 to string 17 overrideFilename string 18 asType AsType 19 format *formats.Format 20 }{ 21 {"Mela", "", AsTypeAny, mela.FormatInfo}, 22 {"mela", "", AsTypeAny, mela.FormatInfo}, 23 {".melarecipe", "", AsTypeRecipe, mela.FormatInfo}, 24 {".melarecipes", "", AsTypeCollection, mela.FormatInfo}, 25 {"something.melarecipe", "something", AsTypeRecipe, mela.FormatInfo}, 26 {"another.melarecipes", "another", AsTypeCollection, mela.FormatInfo}, 27 28 {".protectedrecipes", "", AsTypeCollection, mela.ProtectedFormatInfo}, 29 {"book.protectedrecipes", "book", AsTypeCollection, mela.ProtectedFormatInfo}, 30 31 {"Crouton", "", AsTypeAny, crouton.FormatInfo}, 32 {"crouton", "", AsTypeAny, crouton.FormatInfo}, 33 {".crumb", "", AsTypeRecipe, crouton.FormatInfo}, 34 {"something.crumb", "something", AsTypeRecipe, crouton.FormatInfo}, 35 36 {"Cooklang", "", AsTypeAny, cooklang.FormatInfo}, 37 {"cooklang", "", AsTypeAny, cooklang.FormatInfo}, 38 {".cook", "", AsTypeRecipe, cooklang.FormatInfo}, 39 {"something.cook", "something", AsTypeRecipe, cooklang.FormatInfo}, 40 41 {"nope", "", AsTypeAny, nil}, 42 {".nope", "", AsTypeAny, nil}, 43 {"whatever.nope", "", AsTypeAny, nil}, 44 } 45 46 for _, c := range tc { 47 t.Run(c.to, func(t *testing.T) { 48 overrideFilename, asType, format := ParseDestination(c.to) 49 assert.Equal(t, c.overrideFilename, overrideFilename) 50 assert.Equal(t, c.asType, asType) 51 assert.Equal(t, c.format, format) 52 }) 53 } 54}