github.com/codingfuture/orig-energi3@v0.8.4/cmd/utils/flags_test.go (about) 1 // Copyright 2019 The Energi Core Authors 2 // Copyright 2018 The go-ethereum Authors 3 // This file is part of Energi Core. 4 // 5 // Energi Core is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Energi Core is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Energi Core. If not, see <http://www.gnu.org/licenses/>. 17 18 // Package utils contains internal helper functions for go-ethereum commands. 19 package utils 20 21 import ( 22 "reflect" 23 "testing" 24 ) 25 26 func Test_SplitTagsFlag(t *testing.T) { 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 t.Run(tt.name, func(t *testing.T) { 60 if got := SplitTagsFlag(tt.args); !reflect.DeepEqual(got, tt.want) { 61 t.Errorf("splitTagsFlag() = %v, want %v", got, tt.want) 62 } 63 }) 64 } 65 }