github.com/ethereum/go-ethereum@v1.14.4-0.20240516095835-473ee8fc07a3/cmd/utils/flags_test.go (about) 1 // Copyright 2019 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU 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 // go-ethereum 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 General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. 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 "reflect" 22 "testing" 23 ) 24 25 func Test_SplitTagsFlag(t *testing.T) { 26 t.Parallel() 27 tests := []struct { 28 name string 29 args string 30 want map[string]string 31 }{ 32 { 33 "2 tags case", 34 "host=localhost,bzzkey=123", 35 map[string]string{ 36 "host": "localhost", 37 "bzzkey": "123", 38 }, 39 }, 40 { 41 "1 tag case", 42 "host=localhost123", 43 map[string]string{ 44 "host": "localhost123", 45 }, 46 }, 47 { 48 "empty case", 49 "", 50 map[string]string{}, 51 }, 52 { 53 "garbage", 54 "smth=smthelse=123", 55 map[string]string{}, 56 }, 57 } 58 for _, tt := range tests { 59 tt := tt 60 t.Run(tt.name, func(t *testing.T) { 61 t.Parallel() 62 if got := SplitTagsFlag(tt.args); !reflect.DeepEqual(got, tt.want) { 63 t.Errorf("splitTagsFlag() = %v, want %v", got, tt.want) 64 } 65 }) 66 } 67 }