MCPcopy Index your code
hub / github.com/celer-pkg/celer / TestParseNFSClientDir

Function TestParseNFSClientDir

pkgcache/cache_setup_test.go:10–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestParseNFSClientDir(t *testing.T) {
11 tests := []struct {
12 name string
13 value string
14 wantMountPoint string
15 wantServerExport string
16 wantErr string
17 }{
18 {
19 name: "valid",
20 value: "/mnt/cache@server:/exports/cache",
21 wantMountPoint: "/mnt/cache",
22 wantServerExport: "server:/exports/cache",
23 },
24 {
25 name: "missing separator",
26 value: "/mnt/cache",
27 wantErr: "--nfs-client-dir format: <mount_point>@<server>:<export_path>",
28 },
29 {
30 name: "empty mount point",
31 value: "@server:/exports/cache",
32 wantErr: "--nfs-client-dir format: <mount_point>@<server>:<export_path>",
33 },
34 {
35 name: "empty server export",
36 value: "/mnt/cache@",
37 wantErr: "--nfs-client-dir format: <mount_point>@<server>:<export_path>",
38 },
39 {
40 name: "server export missing colon",
41 value: "/mnt/cache@server",
42 wantErr: "--nfs-client-dir: server export must be in <server>:<path> format",
43 },
44 }
45
46 for _, test := range tests {
47 t.Run(test.name, func(t *testing.T) {
48 gotMountPoint, gotServerExport, err := parseNFSClientDir(test.value)
49 if test.wantErr != "" {
50 if err == nil || err.Error() != test.wantErr {
51 t.Fatalf("parseNFSClientDir() error = %v, want %q", err, test.wantErr)
52 }
53 return
54 }
55 if err != nil {
56 t.Fatalf("parseNFSClientDir() error = %v", err)
57 }
58 if gotMountPoint != test.wantMountPoint || gotServerExport != test.wantServerExport {
59 t.Fatalf("parseNFSClientDir() = (%q, %q), want (%q, %q)", gotMountPoint, gotServerExport, test.wantMountPoint, test.wantServerExport)
60 }
61 })
62 }
63}
64
65func TestShellQuote(t *testing.T) {
66 tests := []struct {

Callers

nothing calls this directly

Calls 2

parseNFSClientDirFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected