Debian Codegraph @

fish_test.go

raw symbols SCIP
1 package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/
2
3 import (
4 "contextscip-go gomod github.com/golang/go/src go1.22 context/"
5 "fmtscip-go gomod github.com/golang/go/src go1.22 fmt/"
6 "testingscip-go gomod github.com/golang/go/src go1.22 testing/"
7
8 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
9 "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/"
10 )
11
12 func TestFishCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestFishCompletion().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
13 // Given
14 cmd := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
15 cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags. = append(cmd.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Flags.,
16 &StringFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/StringFlag#{
17 Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "logfile",
18 TakesFilescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#TakesFile.: true,
19 },
20 &StringSliceFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/StringSliceFlag#{
21 Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#Name.: "foofile",
22 TakesFilescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagBase#TakesFile.: true,
23 })
24 cmd.setupCommandGraphscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setupCommandGraph().()
25
26 oldTemplate := FishCompletionTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FishCompletionTemplate.
27 defer func() { FishCompletionTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FishCompletionTemplate. = oldTemplate }()
28 FishCompletionTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FishCompletionTemplate. = "{{something"
29
30 // test error case
31 _, err1 := cmd.ToFishCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ToFishCompletion().()
32 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Error().(t, err1)
33
34 // reset the template
35 FishCompletionTemplatescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FishCompletionTemplate. = oldTemplate
36 // When
37 res, err := cmd.ToFishCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ToFishCompletion().()
38
39 // Then
40 requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err)
41 expectFileContentscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/expectFileContent().(t, "testdata/expected-fish-full.fish", res)
42 }
43
44 func TestFishCompletionShellCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/TestFishCompletionShellComplete().(t *testingscip-go gomod github.com/golang/go/src go1.22 testing/.Tscip-go gomod github.com/golang/go/src go1.22 testing/T#) {
45 cmd := buildExtendedTestCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/buildExtendedTestCommand().()
46 cmd.ShellCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ShellComplete. = func(contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {}
47
48 configCmd := cmd.Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().("config")
49 configCmd.ShellCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ShellComplete. = func(contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {}
50
51 subConfigCmd := configCmd.Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Command().("sub-config")
52 subConfigCmd.ShellCompletescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ShellComplete. = func(contextscip-go gomod github.com/golang/go/src go1.22 context/.Contextscip-go gomod github.com/golang/go/src go1.22 context/Context#, *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) {}
53
54 cmd.setupCommandGraphscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#setupCommandGraph().()
55
56 res, err := cmd.ToFishCompletionscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#ToFishCompletion().()
57 requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err)
58
59 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Contains().(t, res, fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("complete -c greet -n '__fish_greet_no_subcommand' -xa '(greet %s 2>/dev/null)'", completionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/completionFlag.))
60 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Contains().(t, res, fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("complete -c greet -n '__fish_seen_subcommand_from config c' -xa '(greet config %s 2>/dev/null)'", completionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/completionFlag.))
61 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Contains().(t, res, fmtscip-go gomod github.com/golang/go/src go1.22 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.22 fmt/Sprintf().("complete -c greet -n '__fish_seen_subcommand_from config c; and __fish_seen_subcommand_from sub-config s ss' -xa '(greet config sub-config %s 2>/dev/null)'", completionFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/completionFlag.))
62 }