mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
e2e: test put command with '--ignore-value' flag
This commit is contained in:
parent
e03850c4ac
commit
5dffa38fb2
@ -28,6 +28,7 @@ func TestCtlV3PutTimeout(t *testing.T) { testCtl(t, putTest, withDialTimeo
|
|||||||
func TestCtlV3PutClientTLSFlagByEnv(t *testing.T) {
|
func TestCtlV3PutClientTLSFlagByEnv(t *testing.T) {
|
||||||
testCtl(t, putTest, withCfg(configClientTLS), withFlagByEnv())
|
testCtl(t, putTest, withCfg(configClientTLS), withFlagByEnv())
|
||||||
}
|
}
|
||||||
|
func TestCtlV3PutIgnoreValue(t *testing.T) { testCtl(t, putTestIgnoreValue) }
|
||||||
|
|
||||||
func TestCtlV3Get(t *testing.T) { testCtl(t, getTest) }
|
func TestCtlV3Get(t *testing.T) { testCtl(t, getTest) }
|
||||||
func TestCtlV3GetNoTLS(t *testing.T) { testCtl(t, getTest, withCfg(configNoTLS)) }
|
func TestCtlV3GetNoTLS(t *testing.T) { testCtl(t, getTest, withCfg(configNoTLS)) }
|
||||||
@ -62,6 +63,21 @@ func putTest(cx ctlCtx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func putTestIgnoreValue(cx ctlCtx) {
|
||||||
|
if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ctlV3Get(cx, []string{"foo"}, kv{"foo", "bar"}); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ctlV3Put(cx, "foo", "", "", "--ignore-value"); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ctlV3Get(cx, []string{"foo"}, kv{"foo", "bar"}); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getTest(cx ctlCtx) {
|
func getTest(cx ctlCtx) {
|
||||||
var (
|
var (
|
||||||
kvs = []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}}
|
kvs = []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}}
|
||||||
@ -227,11 +243,24 @@ func delTest(cx ctlCtx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ctlV3Put(cx ctlCtx, key, value, leaseID string) error {
|
func ctlV3Put(cx ctlCtx, key, value, leaseID string, flags ...string) error {
|
||||||
cmdArgs := append(cx.PrefixArgs(), "put", key, value)
|
skipValue := false
|
||||||
|
for _, f := range flags {
|
||||||
|
if f == "--ignore-value" {
|
||||||
|
skipValue = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmdArgs := append(cx.PrefixArgs(), "put", key)
|
||||||
|
if !skipValue {
|
||||||
|
cmdArgs = append(cmdArgs, value)
|
||||||
|
}
|
||||||
if leaseID != "" {
|
if leaseID != "" {
|
||||||
cmdArgs = append(cmdArgs, "--lease", leaseID)
|
cmdArgs = append(cmdArgs, "--lease", leaseID)
|
||||||
}
|
}
|
||||||
|
if len(flags) != 0 {
|
||||||
|
cmdArgs = append(cmdArgs, flags...)
|
||||||
|
}
|
||||||
return spawnWithExpect(cmdArgs, "OK")
|
return spawnWithExpect(cmdArgs, "OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user