add a test for file ext based format detection

This commit is contained in:
ryenus 2024-08-05 11:45:34 +08:00
parent 0e7f9ad4f6
commit 6298fe0f1a

View File

@ -50,3 +50,13 @@ func TestFormatFromString(t *testing.T) {
}
}
}
func TestFormatStringFromFilename(t *testing.T) {
test.AssertResult(t, "yaml", FormatStringFromFilename("test.Yaml"))
test.AssertResult(t, "yaml", FormatStringFromFilename("test.index.Yaml"))
test.AssertResult(t, "yaml", FormatStringFromFilename("test"))
test.AssertResult(t, "json", FormatStringFromFilename("test.json"))
test.AssertResult(t, "json", FormatStringFromFilename("TEST.JSON"))
test.AssertResult(t, "yaml", FormatStringFromFilename("test.json/foo"))
test.AssertResult(t, "yaml", FormatStringFromFilename(""))
}