MCPcopy Index your code
hub / github.com/coder/coder / TestClassifyStoredMediaType

Function TestClassifyStoredMediaType

coderd/x/chatfiles/mime_test.go:20–127  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func TestClassifyStoredMediaType(t *testing.T) {
21 t.Parallel()
22
23 tests := []struct {
24 name string
25 fileName string
26 data []byte
27 want string
28 }{
29 {
30 name: "PlainText",
31 fileName: "build.log",
32 data: []byte("build succeeded\n"),
33 want: "text/plain",
34 },
35 {
36 name: "MarkdownFromExtension",
37 fileName: "notes.md",
38 data: []byte("# Release notes\n"),
39 want: "text/markdown",
40 },
41 {
42 name: "CSVFromDetector",
43 fileName: "report.txt",
44 data: []byte("name,count\nwidgets,3\n"),
45 want: "text/csv",
46 },
47 {
48 name: "JSONFromDetector",
49 fileName: "payload.txt",
50 data: []byte(`{"ok":true}`),
51 want: "application/json",
52 },
53 {
54 name: "UppercaseJSONExtension",
55 fileName: "data.JSON",
56 data: []byte(`{"ok":true}`),
57 want: "application/json",
58 },
59 {
60 name: "InvalidJSONExtensionFallsBackToPlainText",
61 fileName: "broken.json",
62 data: []byte("not json"),
63 want: "text/plain",
64 },
65 {
66 name: "UppercaseMDExtension",
67 fileName: "NOTES.MD",
68 data: []byte("# Notes\n"),
69 want: "text/markdown",
70 },
71 {
72 name: "PDF",
73 fileName: "report.pdf",
74 data: []byte("%PDF-1.7\n"),
75 want: "application/pdf",
76 },
77 {

Callers

nothing calls this directly

Calls 3

ClassifyStoredMediaTypeFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected