gitee.com/liu-zhao234568/cntest@v1.0.0/cmd/utils/prompt_test.go (about)

     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  
    17  // Package utils contains internal helper functions for go-ethereum commands.
    18  package utils
    19  
    20  import (
    21  	"testing"
    22  )
    23  
    24  func TestGetPassPhraseWithList(t *testing.T) {
    25  	type args struct {
    26  		text         string
    27  		confirmation bool
    28  		index        int
    29  		passwords    []string
    30  	}
    31  	tests := []struct {
    32  		name string
    33  		args args
    34  		want string
    35  	}{
    36  		{
    37  			"test1",
    38  			args{
    39  				"text1",
    40  				false,
    41  				0,
    42  				[]string{"zero", "one", "two"},
    43  			},
    44  			"zero",
    45  		},
    46  		{
    47  			"test2",
    48  			args{
    49  				"text2",
    50  				false,
    51  				5,
    52  				[]string{"zero", "one", "two"},
    53  			},
    54  			"two",
    55  		},
    56  		{
    57  			"test3",
    58  			args{
    59  				"text3",
    60  				true,
    61  				1,
    62  				[]string{"zero", "one", "two"},
    63  			},
    64  			"one",
    65  		},
    66  	}
    67  	for _, tt := range tests {
    68  		t.Run(tt.name, func(t *testing.T) {
    69  			if got := GetPassPhraseWithList(tt.args.text, tt.args.confirmation, tt.args.index, tt.args.passwords); got != tt.want {
    70  				t.Errorf("GetPassPhraseWithList() = %v, want %v", got, tt.want)
    71  			}
    72  		})
    73  	}
    74  }