MCPcopy Index your code
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestCommandOptions

Function TestCommandOptions

cmd/options_test.go:33–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestCommandOptions(t *testing.T) {
34 logger := log.NewStdLogger(io.Discard, io.Discard)
35 dialer := &testDialer{}
36 tcs := []struct {
37 desc string
38 isValid func(*Command) error
39 option Option
40 skip bool
41 }{
42 {
43 desc: "with logger",
44 isValid: func(c *Command) error {
45 if c.logger != logger {
46 return errors.New("loggers do not match")
47 }
48 return nil
49 },
50 option: WithLogger(logger),
51 },
52 {
53 desc: "with dialer",
54 isValid: func(c *Command) error {
55 if c.dialer != dialer {
56 return errors.New("dialers do not match")
57 }
58 return nil
59 },
60 option: WithDialer(dialer),
61 },
62 {
63 desc: "with FUSE dir",
64 isValid: func(c *Command) error {
65 if c.conf.FUSEDir != "somedir" {
66 return fmt.Errorf(
67 "want = %v, got = %v", "somedir", c.conf.FUSEDir,
68 )
69 }
70 return nil
71 },
72 option: WithFuseDir("somedir"),
73 // FUSE isn't available on GitHub macOS runners
74 // and FUSE isn't supported on Windows, so skip this test.
75 skip: runtime.GOOS == "darwin" || runtime.GOOS == "windows",
76 },
77 {
78 desc: "with FUSE temp dir",
79 isValid: func(c *Command) error {
80 if c.conf.FUSETempDir != "somedir" {
81 return fmt.Errorf(
82 "want = %v, got = %v", "somedir", c.conf.FUSEDir,
83 )
84 }
85 return nil
86 },
87 option: WithFuseTempDir("somedir"),
88 // FUSE isn't available on GitHub macOS runners
89 // and FUSE isn't supported on Windows, so skip this test.
90 skip: runtime.GOOS == "darwin" || runtime.GOOS == "windows",

Callers

nothing calls this directly

Calls 12

NewStdLoggerFunction · 0.92
WithLoggerFunction · 0.85
WithDialerFunction · 0.85
WithFuseDirFunction · 0.85
WithFuseTempDirFunction · 0.85
WithMaxConnectionsFunction · 0.85
WithUserAgentFunction · 0.85
WithAutoIPFunction · 0.85
WithQuietLoggingFunction · 0.85
WithLazyRefreshFunction · 0.85
invokeProxyWithOptionFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected