prompt_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2020 The go-ethereum Authors
  2. // This file is part of go-ethereum.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. // Package utils contains internal helper functions for go-ethereum commands.
  17. package utils
  18. import (
  19. "testing"
  20. )
  21. func TestGetPassPhraseWithList(t *testing.T) {
  22. type args struct {
  23. text string
  24. confirmation bool
  25. index int
  26. passwords []string
  27. }
  28. tests := []struct {
  29. name string
  30. args args
  31. want string
  32. }{
  33. {
  34. "test1",
  35. args{
  36. "text1",
  37. false,
  38. 0,
  39. []string{"zero", "one", "two"},
  40. },
  41. "zero",
  42. },
  43. {
  44. "test2",
  45. args{
  46. "text2",
  47. false,
  48. 5,
  49. []string{"zero", "one", "two"},
  50. },
  51. "two",
  52. },
  53. {
  54. "test3",
  55. args{
  56. "text3",
  57. true,
  58. 1,
  59. []string{"zero", "one", "two"},
  60. },
  61. "one",
  62. },
  63. }
  64. for _, tt := range tests {
  65. t.Run(tt.name, func(t *testing.T) {
  66. if got := GetPassPhraseWithList(tt.args.text, tt.args.confirmation, tt.args.index, tt.args.passwords); got != tt.want {
  67. t.Errorf("GetPassPhraseWithList() = %v, want %v", got, tt.want)
  68. }
  69. })
  70. }
  71. }