MCPcopy Create free account
hub / github.com/docker/cli / TestLoginValidateFlags

Function TestLoginValidateFlags

cli/command/registry/login_test.go:655–726  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

653}
654
655func TestLoginValidateFlags(t *testing.T) {
656 for _, tc := range []struct {
657 name string
658 args []string
659 expectedErr string
660 }{
661 {
662 name: "--password-stdin without --username",
663 args: []string{"--password-stdin"},
664 expectedErr: `the --password-stdin option requires --username to be set`,
665 },
666 {
667 name: "--password-stdin with empty --username",
668 args: []string{"--password-stdin", "--username", ""},
669 expectedErr: `username is empty`,
670 },
671 {
672 name: "empty --username",
673 args: []string{"--username", ""},
674 expectedErr: `username is empty`,
675 },
676 {
677 name: "--username without value",
678 args: []string{"--username"},
679 expectedErr: `flag needs an argument: --username`,
680 },
681 {
682 name: "conflicting options --password-stdin and --password",
683 args: []string{"--password-stdin", "--password", ""},
684 expectedErr: `conflicting options: cannot specify both --password and --password-stdin`,
685 },
686 {
687 name: "password stdin and password dash without stdin",
688 args: []string{"--password-stdin", "--username", "my-username", "--password", "-"},
689 expectedErr: `password is empty`,
690 },
691 {
692 name: "password dash without username",
693 args: []string{"--password", "-"},
694 expectedErr: `the --password-stdin option requires --username to be set`,
695 },
696 {
697 name: "short password dash without username",
698 args: []string{"-p", "-"},
699 expectedErr: `the --password-stdin option requires --username to be set`,
700 },
701 {
702 name: "empty --password",
703 args: []string{"--password", ""},
704 expectedErr: `password is empty`,
705 },
706 {
707 name: "--password without value",
708 args: []string{"--password"},
709 expectedErr: `flag needs an argument: --password`,
710 },
711 } {
712 t.Run(tc.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

newLoginCommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…