MCPcopy Index your code
hub / github.com/peak/s5cmd / TestGenerateCommand

Function TestGenerateCommand

command/context_test.go:12–194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestGenerateCommand(t *testing.T) {
13 t.Parallel()
14
15 app := cli.NewApp()
16
17 testcases := []struct {
18 name string
19 cmd string
20 flags []cli.Flag
21 defaultFlags map[string]interface{}
22 ctx *cli.Context
23 urls []*url.URL
24 expectedCommand string
25 }{
26 {
27 name: "empty-cli-flags",
28 cmd: "cp",
29 flags: []cli.Flag{},
30 urls: []*url.URL{
31 mustNewURL(t, "s3://bucket/key1"),
32 mustNewURL(t, "s3://bucket/key2"),
33 },
34 expectedCommand: `cp "s3://bucket/key1" "s3://bucket/key2"`,
35 },
36 {
37 name: "empty-cli-flags-with-default-flags",
38 cmd: "cp",
39 flags: []cli.Flag{},
40 defaultFlags: map[string]interface{}{
41 "raw": true,
42 "acl": "public-read",
43 },
44 urls: []*url.URL{
45 mustNewURL(t, "s3://bucket/key1"),
46 mustNewURL(t, "s3://bucket/key2"),
47 },
48 expectedCommand: `cp --acl='public-read' --raw='true' "s3://bucket/key1" "s3://bucket/key2"`,
49 },
50 {
51 name: "cli-flag-with-whitespaced-flag-value",
52 cmd: "cp",
53 flags: []cli.Flag{
54 &cli.StringFlag{
55 Name: "cache-control",
56 Value: "public, max-age=31536000, immutable",
57 },
58 },
59 defaultFlags: map[string]interface{}{
60 "raw": true,
61 },
62 urls: []*url.URL{
63 mustNewURL(t, "s3://bucket/key1"),
64 mustNewURL(t, "s3://bucket/key2"),
65 },
66 expectedCommand: `cp --cache-control='public, max-age=31536000, immutable' --raw='true' "s3://bucket/key1" "s3://bucket/key2"`,
67 },
68 {
69 name: "same-flag-should-be-ignored-if-given-from-both-default-and-cli-flags",

Callers

nothing calls this directly

Calls 7

mustNewURLFunction · 0.85
AppCommandFunction · 0.85
flagSetFunction · 0.85
generateCommandFunction · 0.85
RunMethod · 0.45
SetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected