-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Add sequencer network config selection to
sequencer
comman…
…ds (#139) * add sequencer networks config and network flag to sequencer transfer command * update transfer command handler to use ChooseFlagValue func * move get network value * typo fix * add network config to remaining sequencer commands * add network flag to sequencer commands * make config structs more generic so we can easily add new networks * fix some doc comments * remove info log statement to fix tests * attempt to simplify flag handling with network config * update doc comment * add override flag option to flag handler * add CreateCliFlagHandlerWithOverrideFlag * put all logic in GetValue * update commands to use new GetValue * remove unneeded functions * update getField name Co-authored-by: jesse snyder <[email protected]> * update getField comment Co-authored-by: jesse snyder <[email protected]> * address pr comments --------- Co-authored-by: Jesse Snyder <[email protected]>
- Loading branch information
1 parent
04c7cba
commit 58a9817
Showing
17 changed files
with
375 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGetFieldValueByTag(t *testing.T) { | ||
type testStruct struct { | ||
Field1 string `flag:"field-1"` | ||
Field2 int `tag2:"field-2"` | ||
Field3 bool `b:"field-3"` | ||
} | ||
|
||
s := testStruct{ | ||
Field1: "value1", | ||
Field2: 1, | ||
Field3: true, | ||
} | ||
|
||
t.Run("Get field by tag", func(t *testing.T) { | ||
val1, ok := GetFieldValueByTag(s, "flag", "field-1") | ||
if !ok { | ||
t.Errorf("Expected to find field by tag") | ||
} | ||
if val1.String() != "value1" { | ||
t.Errorf("Expected field value to be %s, got %s", s.Field1, val1.String()) | ||
} | ||
|
||
val2, ok := GetFieldValueByTag(s, "tag2", "field-2") | ||
if !ok { | ||
t.Errorf("Expected to find field by tag") | ||
} | ||
if val2.Int() != 1 { | ||
t.Errorf("Expected field value to be %d, got %s", s.Field2, val2.String()) | ||
} | ||
|
||
val3, ok := GetFieldValueByTag(s, "b", "field-3") | ||
if !ok { | ||
t.Errorf("Expected to find field by tag") | ||
} | ||
if val3.Bool() != true { | ||
t.Errorf("Expected field value to be %t, got %s", s.Field3, val3.String()) | ||
} | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.