Skip to content

Commit ff9a814

Browse files
committed
feat: add unit test for cmd building
1 parent 6ee95d7 commit ff9a814

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

cmd/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func startCommand() *cobra.Command {
4040
timelock.SetReadyStatus(timelock.HealthStatusError)
4141

4242
startCmd.Flags().StringVarP(&nodeURL, "node-url", "n", timelockConf.NodeURL, "RPC Endpoint for the target blockchain")
43-
startCmd.Flags().StringVarP(&chainFamily, "chain-family", "n", timelockConf.ChainFamily, "Chain family of the target blockchain (evm, solana)")
43+
startCmd.Flags().StringVarP(&chainFamily, "chain-family", "c", timelockConf.ChainFamily, "Chain family of the target blockchain (evm, solana)")
4444
startCmd.Flags().StringVarP(&timelockAddress, "timelock-address", "a", timelockConf.TimelockAddress, "Address of the target Timelock contract")
4545
startCmd.Flags().StringVarP(&callProxyAddress, "call-proxy-address", "f", timelockConf.CallProxyAddress, "Address of the target CallProxyAddress contract")
4646
startCmd.Flags().StringVarP(&privateKey, "private-key", "k", timelockConf.PrivateKey, "Private key used to execute transactions")

cmd/start_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package cmd
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestStartCommand_HasExpectedFlags(t *testing.T) {
10+
command := startCommand()
11+
12+
flags := command.Flags()
13+
14+
tests := []struct {
15+
name string
16+
}{
17+
{"node-url"},
18+
{"chain-family"},
19+
{"timelock-address"},
20+
{"call-proxy-address"},
21+
{"private-key"},
22+
{"from-block"},
23+
{"poll-period"},
24+
{"event-listener-poll-period"},
25+
{"event-listener-poll-size"},
26+
{"dry-run"},
27+
}
28+
29+
for _, tt := range tests {
30+
t.Run(tt.name, func(t *testing.T) {
31+
32+
assert.NotNil(t, flags.Lookup(tt.name), "flag '%s' should be defined", tt.name)
33+
})
34+
}
35+
}

0 commit comments

Comments
 (0)