MCPcopy Index your code
hub / github.com/docker/cli / TestRequiresMaxArgs

Function TestRequiresMaxArgs

cli/required_test.go:54–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestRequiresMaxArgs(t *testing.T) {
55 testCases := []testCase{
56 {
57 validateFunc: RequiresMaxArgs(0),
58 expectedError: "no error",
59 },
60 {
61 args: []string{"foo", "bar"},
62 validateFunc: RequiresMaxArgs(1),
63 expectedError: "at most 1 argument",
64 },
65 {
66 args: []string{"foo", "bar", "baz"},
67 validateFunc: RequiresMaxArgs(2),
68 expectedError: "at most 2 arguments",
69 },
70 }
71 for _, tc := range testCases {
72 cmd := newDummyCommand(tc.validateFunc)
73 cmd.SetArgs(tc.args)
74 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
75 }
76}
77
78func TestRequiresRangeArgs(t *testing.T) {
79 testCases := []testCase{

Callers

nothing calls this directly

Calls 3

RequiresMaxArgsFunction · 0.85
newDummyCommandFunction · 0.85
SetArgsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…