Skip to content

Commit

Permalink
Remove unused value option in add command
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Mar 8, 2019
1 parent 6d52272 commit 9647abb
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ source of ordered events like logs, ledgers, etc...
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8800 \
--endpoints http://localhost:8800 \
add \
--key 'test event' \
--value 2 \
--log info
```
Expand All @@ -109,7 +108,7 @@ source of ordered events like logs, ledgers, etc...
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8800 \
--endpoints http://localhost:8800 \
membership \
--hyperDigest 3ec11c37f0a53ff5c4cfc3cf2573c33a9721cd25d8e670a3b2be0fda5724bb5c \
--historyDigest 776b33eab8ed829ecffab3d579bf7ccbcc126b94bac1aaca7d5d8b0a2687bdec \
Expand Down
6 changes: 2 additions & 4 deletions cmd/client_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

func newAddCommand(ctx *clientContext, clientPreRun func(*cobra.Command, []string)) *cobra.Command {

var key, value string
var key string

cmd := &cobra.Command{
Use: "add",
Expand All @@ -36,7 +36,7 @@ func newAddCommand(ctx *clientContext, clientPreRun func(*cobra.Command, []strin
clientPreRun(cmd, args)
},
RunE: func(cmd *cobra.Command, args []string) error {
log.Infof("Adding key [ %s ] with value [ %s ]\n", key, value)
log.Infof("Adding key [ %s ]\n", key)
// SilenceUsage is set to true -> https://github.com/spf13/cobra/issues/340
cmd.SilenceUsage = true
snapshot, err := ctx.client.Add(key)
Expand All @@ -61,9 +61,7 @@ Received snapshot with values:
}

cmd.Flags().StringVar(&key, "key", "", "Key to add")
cmd.Flags().StringVar(&value, "value", "", "Value to add")
cmd.MarkFlagRequired("key")
cmd.MarkFlagRequired("value")

return cmd
}
5 changes: 2 additions & 3 deletions tests/add_verify
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ QED="go run ../main.go -l info -k path"

add_event(){
local event="$1"; shift
local value="$1"; shift
$QED client add --key "${event}" --value "${value}"
$QED client add --key "${event}"
}


#Adding key [ test event ] with value [ 2 ]
#Adding key [ test event ]
#test event
#Received snapshot with values:
# Event: test event
Expand Down
2 changes: 1 addition & 1 deletion tests/demo/add-events
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
echo 'Add multiple events...'
go build -o qed ../..
for i in $(seq 0 9); do
./qed -k test_key client add --key $i --value $i -l info
./qed -k test_key client add --key $i -l info
done
rm -f qed
echo done.
6 changes: 0 additions & 6 deletions tests/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func Test_Client_To_Single_Server(t *testing.T) {
fmt.Sprintf("--endpoints=%s", QEDTLS),
"add",
"--key='test event'",
"--value=2",
"--log=info",
"--insecure",
)
Expand Down Expand Up @@ -122,7 +121,6 @@ func Test_Client_To_Cluster_With_Leader_Change(t *testing.T) {
fmt.Sprintf("--endpoints=%s", serversHttpAddr),
"add",
"--key='test event'",
"--value=2",
"--log=info",
)

Expand Down Expand Up @@ -194,7 +192,6 @@ func Test_Client_To_Cluster_With_Leader_Change(t *testing.T) {
fmt.Sprintf("--endpoints=%s", serversHttpAddr),
"add",
"--key='test event 2'",
"--value=2",
"--log=info",
)

Expand Down Expand Up @@ -223,7 +220,6 @@ func Test_Client_To_Cluster_With_Bad_Endpoint(t *testing.T) {
fmt.Sprintf("--endpoints=badendpoint,http://127.0.0.1:8800"),
"add",
"--key='test event'",
"--value=2",
"--log=info",
)

Expand All @@ -241,7 +237,6 @@ func Test_Client_To_Cluster_With_Bad_Endpoint(t *testing.T) {
fmt.Sprintf("--endpoints=badendpoint"),
"add",
"--key='test event'",
"--value=2",
"--log=info",
)

Expand Down Expand Up @@ -272,7 +267,6 @@ func Test_Client_To_Cluster_Continuous_Load_Node_Fails(t *testing.T) {
fmt.Sprintf("--endpoints=%s", serversHttpAddr),
"add",
"--key='test event'",
"--value=2",
"--log=info",
)

Expand Down
2 changes: 1 addition & 1 deletion tests/gossip/add.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

go run $GOPATH/src/github.com/bbva/qed/main.go client add -k key -e http://127.0.0.1:8800 --key key$1 --value value$1
go run $GOPATH/src/github.com/bbva/qed/main.go client add --apikey foo -e http://127.0.0.1:8800 --key key$1

0 comments on commit 9647abb

Please sign in to comment.