diff options
Diffstat (limited to 'output/outputFormat_test.go')
-rw-r--r-- | output/outputFormat_test.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/output/outputFormat_test.go b/output/outputFormat_test.go index e742012ba..b73e53f82 100644 --- a/output/outputFormat_test.go +++ b/output/outputFormat_test.go @@ -65,7 +65,7 @@ func TestDefaultTypes(t *testing.T) { } -func TestGetType(t *testing.T) { +func TestGetFormat(t *testing.T) { tp, _ := GetFormat("html") require.Equal(t, HTMLFormat, tp) tp, _ = GetFormat("HTML") @@ -73,3 +73,28 @@ func TestGetType(t *testing.T) { _, found := GetFormat("FOO") require.False(t, found) } + +func TestGeGetFormatByName(t *testing.T) { + formats := Formats{AMPFormat, CalendarFormat} + tp, _ := formats.GetByName("AMP") + require.Equal(t, AMPFormat, tp) + _, found := formats.GetByName("HTML") + require.False(t, found) + _, found = formats.GetByName("FOO") + require.False(t, found) +} + +func TestGeGetFormatByExt(t *testing.T) { + formats1 := Formats{AMPFormat, CalendarFormat} + formats2 := Formats{AMPFormat, HTMLFormat, CalendarFormat} + tp, _ := formats1.GetBySuffix("html") + require.Equal(t, AMPFormat, tp) + tp, _ = formats1.GetBySuffix("ics") + require.Equal(t, CalendarFormat, tp) + _, found := formats1.GetBySuffix("not") + require.False(t, found) + + // ambiguous + _, found = formats2.GetByName("html") + require.False(t, found) +} |