-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ty/fix-chain_id
- Loading branch information
Showing
9 changed files
with
484 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package cmd | ||
|
||
// RunCosmovisorCommands executes cosmosvisor commands e.g `cosmovisor version` | ||
func RunCosmovisorCommands(args []string) { | ||
if isVersionCommand(args) { | ||
printVersion() | ||
} | ||
} |
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,15 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// Version represents Cosmovisor version value. Set during build | ||
var Version string | ||
|
||
func isVersionCommand(args []string) bool { | ||
return len(args) == 1 && strings.EqualFold(args[0], "version") | ||
} | ||
|
||
func printVersion() { fmt.Println("Cosmovisor Version: ", Version) } |
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,40 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIsVersionCommand(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
args []string | ||
expectRes bool | ||
}{{ | ||
name: "valid args - lowercase", | ||
args: []string{"version"}, | ||
expectRes: true, | ||
}, { | ||
name: "typo", | ||
args: []string{"vrsion"}, | ||
expectRes: false, | ||
}, { | ||
name: "non version command", | ||
args: []string{"start"}, | ||
expectRes: false, | ||
}, { | ||
name: "incorrect format", | ||
args: []string{"start", "version"}, | ||
expectRes: false, | ||
}} | ||
|
||
for i := range cases { | ||
tc := cases[i] | ||
t.Run(tc.name, func(t *testing.T) { | ||
require := require.New(t) | ||
res := isVersionCommand(tc.args) | ||
require.Equal(tc.expectRes, res) | ||
}) | ||
} | ||
} |
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.