-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgdf_test.go
More file actions
55 lines (48 loc) · 1.19 KB
/
Copy pathgdf_test.go
File metadata and controls
55 lines (48 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"bytes"
"strings"
"testing"
"google.golang.org/api/drive/v3"
)
func TestParseArgsRequiresSearchTerms(t *testing.T) {
_, _, err := parseArgs(nil)
if err == nil {
t.Fatal("expected error")
}
}
func TestParseArgsRejectsInvalidPageSize(t *testing.T) {
_, _, err := parseArgs([]string{"-page-size", "1001", "quarterly"})
if err == nil {
t.Fatal("expected error")
}
}
func TestEscapeDriveQueryString(t *testing.T) {
got := escapeDriveQueryString(`Rick's \ Report`)
want := `Rick\'s \\ Report`
if got != want {
t.Fatalf("escapeDriveQueryString() = %q, want %q", got, want)
}
}
func TestPrintFiles(t *testing.T) {
var out bytes.Buffer
printFiles(&out, []*drive.File{
{
Name: "Quarterly Report.pdf",
MimeType: "application/pdf",
Size: 1048576,
ModifiedTime: "2026-06-05T12:00:00Z",
},
{
Name: "Reports",
MimeType: "application/vnd.google-apps.folder",
ModifiedTime: "2026-06-05T12:00:00Z",
},
})
got := out.String()
for _, want := range []string{"Quarterly Report.pdf", "Reports", "folder", "2 files found."} {
if !strings.Contains(got, want) {
t.Fatalf("output %q does not contain %q", got, want)
}
}
}