(t *testing.T)
| 653 | } |
| 654 | |
| 655 | func 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) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…