MCPcopy
hub / github.com/pocketbase/pocketbase / TestUploadedFileSize

Function TestUploadedFileSize

core/validators/file_test.go:12–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestUploadedFileSize(t *testing.T) {
13 t.Parallel()
14
15 file, err := filesystem.NewFileFromBytes([]byte("test"), "test.txt")
16 if err != nil {
17 t.Fatal(err)
18 }
19
20 scenarios := []struct {
21 maxBytes int64
22 file *filesystem.File
23 expectError bool
24 }{
25 {0, nil, false},
26 {4, nil, false},
27 {3, file, true}, // all test files have "test" as content
28 {4, file, false},
29 {5, file, false},
30 }
31
32 for _, s := range scenarios {
33 t.Run(fmt.Sprintf("%d", s.maxBytes), func(t *testing.T) {
34 err := validators.UploadedFileSize(s.maxBytes)(s.file)
35
36 hasErr := err != nil
37 if hasErr != s.expectError {
38 t.Fatalf("Expected hasErr to be %v, got %v (%v)", s.expectError, hasErr, err)
39 }
40 })
41 }
42}
43
44func TestUploadedFileMimeType(t *testing.T) {
45 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewFileFromBytesFunction · 0.92
UploadedFileSizeFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…