Merge pull request #13017 from gpavanb1/assert_replace

*: Replace internal testutil AssertEqual function
This commit is contained in:
Piotr Tabor 2021-05-21 11:30:07 +02:00 committed by GitHub
commit e149da312a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 351 additions and 324 deletions

View File

@ -127,6 +127,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=

View File

@ -4,6 +4,7 @@ go 1.16
require ( require (
github.com/coreos/go-systemd/v22 v22.3.1 github.com/coreos/go-systemd/v22 v22.3.1
github.com/stretchr/testify v1.7.0
go.uber.org/zap v1.16.1-0.20210329175301-c23abee72d19 go.uber.org/zap v1.16.1-0.20210329175301-c23abee72d19
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57
google.golang.org/grpc v1.37.0 google.golang.org/grpc v1.37.0

View File

@ -38,8 +38,9 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
@ -89,8 +90,11 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -15,31 +15,23 @@
package testutil package testutil
import ( import (
"fmt"
"reflect" "reflect"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func AssertEqual(t *testing.T, e, a interface{}, msg ...string) { func copyToInterface(msg ...string) []interface{} {
t.Helper() newMsg := make([]interface{}, len(msg))
if (e == nil || a == nil) && (isNil(e) && isNil(a)) { for i, v := range msg {
return newMsg[i] = v
} }
if reflect.DeepEqual(e, a) { return newMsg
return
}
s := ""
if len(msg) > 0 {
s = msg[0] + ": "
}
s = fmt.Sprintf("%s:expected %+v, got %+v", s, e, a)
FatalStack(t, s)
} }
func AssertNil(t *testing.T, v interface{}) { func AssertNil(t *testing.T, v interface{}) {
t.Helper() t.Helper()
AssertEqual(t, nil, v) assert.Nil(t, v)
} }
func AssertNotNil(t *testing.T, v interface{}) { func AssertNotNil(t *testing.T, v interface{}) {
@ -51,12 +43,14 @@ func AssertNotNil(t *testing.T, v interface{}) {
func AssertTrue(t *testing.T, v bool, msg ...string) { func AssertTrue(t *testing.T, v bool, msg ...string) {
t.Helper() t.Helper()
AssertEqual(t, true, v, msg...) newMsg := copyToInterface(msg...)
assert.Equal(t, true, v, newMsg)
} }
func AssertFalse(t *testing.T, v bool, msg ...string) { func AssertFalse(t *testing.T, v bool, msg ...string) {
t.Helper() t.Helper()
AssertEqual(t, false, v, msg...) newMsg := copyToInterface(msg...)
assert.Equal(t, false, v, newMsg)
} }
func isNil(v interface{}) bool { func isNil(v interface{}) bool {

View File

@ -60,8 +60,9 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
@ -137,9 +138,12 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -116,8 +116,9 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
@ -221,6 +222,8 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=

View File

@ -181,9 +181,11 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
@ -351,6 +353,7 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -493,6 +496,7 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk=
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=

View File

@ -177,9 +177,11 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@ -341,6 +343,7 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -483,6 +486,7 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

1
go.sum
View File

@ -366,6 +366,7 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

View File

@ -14,6 +14,7 @@ github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOi
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/coreos/go-systemd/v22 v22.3.1/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.3.1/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@ -65,6 +66,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
@ -136,7 +139,10 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -24,8 +24,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/client/pkg/v3/srv" "go.etcd.io/etcd/client/pkg/v3/srv"
"go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/client/pkg/v3/transport" "go.etcd.io/etcd/client/pkg/v3/transport"
"go.etcd.io/etcd/client/pkg/v3/types" "go.etcd.io/etcd/client/pkg/v3/types"
@ -80,11 +80,11 @@ func TestConfigFileOtherFields(t *testing.T) {
t.Errorf("PeerTLS = %v, want %v", cfg.PeerTLSInfo, ptls) t.Errorf("PeerTLS = %v, want %v", cfg.PeerTLSInfo, ptls)
} }
testutil.AssertEqual(t, true, cfg.ForceNewCluster, "ForceNewCluster does not match") assert.Equal(t, true, cfg.ForceNewCluster, "ForceNewCluster does not match")
testutil.AssertEqual(t, true, cfg.SocketOpts.ReusePort, "ReusePort does not match") assert.Equal(t, true, cfg.SocketOpts.ReusePort, "ReusePort does not match")
testutil.AssertEqual(t, false, cfg.SocketOpts.ReuseAddress, "ReuseAddress does not match") assert.Equal(t, false, cfg.SocketOpts.ReuseAddress, "ReuseAddress does not match")
} }
// TestUpdateDefaultClusterFromName ensures that etcd can start with 'etcd --name=abc'. // TestUpdateDefaultClusterFromName ensures that etcd can start with 'etcd --name=abc'.

View File

@ -19,7 +19,7 @@ import (
"testing" "testing"
"time" "time"
"go.etcd.io/etcd/client/pkg/v3/testutil" "github.com/stretchr/testify/assert"
) )
func TestNodeExternClone(t *testing.T) { func TestNodeExternClone(t *testing.T) {
@ -56,15 +56,15 @@ func TestNodeExternClone(t *testing.T) {
gNode := eNode.Clone() gNode := eNode.Clone()
// Check the clone is as expected // Check the clone is as expected
testutil.AssertEqual(t, gNode.Key, key) assert.Equal(t, gNode.Key, key)
testutil.AssertEqual(t, gNode.TTL, ttl) assert.Equal(t, gNode.TTL, ttl)
testutil.AssertEqual(t, gNode.CreatedIndex, ci) assert.Equal(t, gNode.CreatedIndex, ci)
testutil.AssertEqual(t, gNode.ModifiedIndex, mi) assert.Equal(t, gNode.ModifiedIndex, mi)
// values should be the same // values should be the same
testutil.AssertEqual(t, *gNode.Value, val) assert.Equal(t, *gNode.Value, val)
testutil.AssertEqual(t, *gNode.Expiration, exp) assert.Equal(t, *gNode.Expiration, exp)
testutil.AssertEqual(t, len(gNode.Nodes), len(childs)) assert.Equal(t, len(gNode.Nodes), len(childs))
testutil.AssertEqual(t, *gNode.Nodes[0], child) assert.Equal(t, *gNode.Nodes[0], child)
// but pointers should differ // but pointers should differ
if gNode.Value == eNode.Value { if gNode.Value == eNode.Value {
t.Fatalf("expected value pointers to differ, but got same!") t.Fatalf("expected value pointers to differ, but got same!")
@ -76,12 +76,12 @@ func TestNodeExternClone(t *testing.T) {
t.Fatalf("expected nodes pointers to differ, but got same!") t.Fatalf("expected nodes pointers to differ, but got same!")
} }
// Original should be the same // Original should be the same
testutil.AssertEqual(t, eNode.Key, key) assert.Equal(t, eNode.Key, key)
testutil.AssertEqual(t, eNode.TTL, ttl) assert.Equal(t, eNode.TTL, ttl)
testutil.AssertEqual(t, eNode.CreatedIndex, ci) assert.Equal(t, eNode.CreatedIndex, ci)
testutil.AssertEqual(t, eNode.ModifiedIndex, mi) assert.Equal(t, eNode.ModifiedIndex, mi)
testutil.AssertEqual(t, eNode.Value, valp) assert.Equal(t, eNode.Value, valp)
testutil.AssertEqual(t, eNode.Expiration, expp) assert.Equal(t, eNode.Expiration, expp)
if !sameSlice(eNode.Nodes, childs) { if !sameSlice(eNode.Nodes, childs) {
t.Fatalf("expected nodes pointer to same, but got different!") t.Fatalf("expected nodes pointer to same, but got different!")
} }
@ -89,15 +89,15 @@ func TestNodeExternClone(t *testing.T) {
gNode.Key = "/baz" gNode.Key = "/baz"
gNode.TTL = 0 gNode.TTL = 0
gNode.Nodes[0].Key = "uno" gNode.Nodes[0].Key = "uno"
testutil.AssertEqual(t, eNode.Key, key) assert.Equal(t, eNode.Key, key)
testutil.AssertEqual(t, eNode.TTL, ttl) assert.Equal(t, eNode.TTL, ttl)
testutil.AssertEqual(t, eNode.CreatedIndex, ci) assert.Equal(t, eNode.CreatedIndex, ci)
testutil.AssertEqual(t, eNode.ModifiedIndex, mi) assert.Equal(t, eNode.ModifiedIndex, mi)
testutil.AssertEqual(t, *eNode.Nodes[0], child) assert.Equal(t, *eNode.Nodes[0], child)
// Change the original and ensure the clone is not affected // Change the original and ensure the clone is not affected
eNode.Key = "/wuf" eNode.Key = "/wuf"
testutil.AssertEqual(t, eNode.Key, "/wuf") assert.Equal(t, eNode.Key, "/wuf")
testutil.AssertEqual(t, gNode.Key, "/baz") assert.Equal(t, gNode.Key, "/baz")
} }
func sameSlice(a, b []*NodeExtern) bool { func sameSlice(a, b []*NodeExtern) bool {

View File

@ -18,7 +18,7 @@ import (
"testing" "testing"
"time" "time"
"go.etcd.io/etcd/client/pkg/v3/testutil" "github.com/stretchr/testify/assert"
) )
// Ensure that a successful Get is recorded in the stats. // Ensure that a successful Get is recorded in the stats.
@ -26,7 +26,7 @@ func TestStoreStatsGetSuccess(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Get("/foo", false, false) s.Get("/foo", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.GetSuccess, "") assert.Equal(t, uint64(1), s.Stats.GetSuccess, "")
} }
// Ensure that a failed Get is recorded in the stats. // Ensure that a failed Get is recorded in the stats.
@ -34,14 +34,14 @@ func TestStoreStatsGetFail(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Get("/no_such_key", false, false) s.Get("/no_such_key", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.GetFail, "") assert.Equal(t, uint64(1), s.Stats.GetFail, "")
} }
// Ensure that a successful Create is recorded in the stats. // Ensure that a successful Create is recorded in the stats.
func TestStoreStatsCreateSuccess(t *testing.T) { func TestStoreStatsCreateSuccess(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CreateSuccess, "") assert.Equal(t, uint64(1), s.Stats.CreateSuccess, "")
} }
// Ensure that a failed Create is recorded in the stats. // Ensure that a failed Create is recorded in the stats.
@ -49,7 +49,7 @@ func TestStoreStatsCreateFail(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CreateFail, "") assert.Equal(t, uint64(1), s.Stats.CreateFail, "")
} }
// Ensure that a successful Update is recorded in the stats. // Ensure that a successful Update is recorded in the stats.
@ -57,14 +57,14 @@ func TestStoreStatsUpdateSuccess(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent}) s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.UpdateSuccess, "") assert.Equal(t, uint64(1), s.Stats.UpdateSuccess, "")
} }
// Ensure that a failed Update is recorded in the stats. // Ensure that a failed Update is recorded in the stats.
func TestStoreStatsUpdateFail(t *testing.T) { func TestStoreStatsUpdateFail(t *testing.T) {
s := newStore() s := newStore()
s.Update("/foo", "bar", TTLOptionSet{ExpireTime: Permanent}) s.Update("/foo", "bar", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.UpdateFail, "") assert.Equal(t, uint64(1), s.Stats.UpdateFail, "")
} }
// Ensure that a successful CAS is recorded in the stats. // Ensure that a successful CAS is recorded in the stats.
@ -72,7 +72,7 @@ func TestStoreStatsCompareAndSwapSuccess(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent}) s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapSuccess, "") assert.Equal(t, uint64(1), s.Stats.CompareAndSwapSuccess, "")
} }
// Ensure that a failed CAS is recorded in the stats. // Ensure that a failed CAS is recorded in the stats.
@ -80,7 +80,7 @@ func TestStoreStatsCompareAndSwapFail(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent}) s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapFail, "") assert.Equal(t, uint64(1), s.Stats.CompareAndSwapFail, "")
} }
// Ensure that a successful Delete is recorded in the stats. // Ensure that a successful Delete is recorded in the stats.
@ -88,14 +88,14 @@ func TestStoreStatsDeleteSuccess(t *testing.T) {
s := newStore() s := newStore()
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
s.Delete("/foo", false, false) s.Delete("/foo", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.DeleteSuccess, "") assert.Equal(t, uint64(1), s.Stats.DeleteSuccess, "")
} }
// Ensure that a failed Delete is recorded in the stats. // Ensure that a failed Delete is recorded in the stats.
func TestStoreStatsDeleteFail(t *testing.T) { func TestStoreStatsDeleteFail(t *testing.T) {
s := newStore() s := newStore()
s.Delete("/foo", false, false) s.Delete("/foo", false, false)
testutil.AssertEqual(t, uint64(1), s.Stats.DeleteFail, "") assert.Equal(t, uint64(1), s.Stats.DeleteFail, "")
} }
//Ensure that the number of expirations is recorded in the stats. //Ensure that the number of expirations is recorded in the stats.
@ -105,8 +105,8 @@ func TestStoreStatsExpireCount(t *testing.T) {
s.clock = fc s.clock = fc
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
testutil.AssertEqual(t, uint64(0), s.Stats.ExpireCount, "") assert.Equal(t, uint64(0), s.Stats.ExpireCount, "")
fc.Advance(600 * time.Millisecond) fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
testutil.AssertEqual(t, uint64(1), s.Stats.ExpireCount, "") assert.Equal(t, uint64(1), s.Stats.ExpireCount, "")
} }

View File

@ -18,6 +18,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/client/pkg/v3/testutil" "go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/server/v3/etcdserver/api/v2error" "go.etcd.io/etcd/server/v3/etcdserver/api/v2error"
@ -38,10 +39,10 @@ func TestMinExpireTime(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
e, err := s.Get("/foo", true, false) e, err := s.Get("/foo", true, false)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "get") assert.Equal(t, e.Action, "get")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
} }
// Ensure that the store can recursively retrieve a directory listing. // Ensure that the store can recursively retrieve a directory listing.
@ -60,19 +61,19 @@ func TestStoreGetDirectory(t *testing.T) {
var eidx uint64 = 7 var eidx uint64 = 7
e, err := s.Get("/foo", true, false) e, err := s.Get("/foo", true, false)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "get") assert.Equal(t, e.Action, "get")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, len(e.Node.Nodes), 2) assert.Equal(t, len(e.Node.Nodes), 2)
var bazNodes NodeExterns var bazNodes NodeExterns
for _, node := range e.Node.Nodes { for _, node := range e.Node.Nodes {
switch node.Key { switch node.Key {
case "/foo/bar": case "/foo/bar":
testutil.AssertEqual(t, *node.Value, "X") assert.Equal(t, *node.Value, "X")
testutil.AssertEqual(t, node.Dir, false) assert.Equal(t, node.Dir, false)
case "/foo/baz": case "/foo/baz":
testutil.AssertEqual(t, node.Dir, true) assert.Equal(t, node.Dir, true)
testutil.AssertEqual(t, len(node.Nodes), 2) assert.Equal(t, len(node.Nodes), 2)
bazNodes = node.Nodes bazNodes = node.Nodes
default: default:
t.Errorf("key = %s, not matched", node.Key) t.Errorf("key = %s, not matched", node.Key)
@ -81,12 +82,12 @@ func TestStoreGetDirectory(t *testing.T) {
for _, node := range bazNodes { for _, node := range bazNodes {
switch node.Key { switch node.Key {
case "/foo/baz/bat": case "/foo/baz/bat":
testutil.AssertEqual(t, *node.Value, "Y") assert.Equal(t, *node.Value, "Y")
testutil.AssertEqual(t, node.Dir, false) assert.Equal(t, node.Dir, false)
case "/foo/baz/ttl": case "/foo/baz/ttl":
testutil.AssertEqual(t, *node.Value, "Y") assert.Equal(t, *node.Value, "Y")
testutil.AssertEqual(t, node.Dir, false) assert.Equal(t, node.Dir, false)
testutil.AssertEqual(t, node.TTL, int64(3)) assert.Equal(t, node.TTL, int64(3))
default: default:
t.Errorf("key = %s, not matched", node.Key) t.Errorf("key = %s, not matched", node.Key)
} }
@ -104,13 +105,13 @@ func TestStoreUpdateValueTTL(t *testing.T) {
_, err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) _, err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
e, _ := s.Get("/foo", false, false) e, _ := s.Get("/foo", false, false)
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
fc.Advance(600 * time.Millisecond) fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
e, err = s.Get("/foo", false, false) e, err = s.Get("/foo", false, false)
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
testutil.AssertEqual(t, err.(*v2error.Error).ErrorCode, v2error.EcodeKeyNotFound) assert.Equal(t, err.(*v2error.Error).ErrorCode, v2error.EcodeKeyNotFound)
} }
// Ensure that the store can update the TTL on a directory. // Ensure that the store can update the TTL on a directory.
@ -126,17 +127,17 @@ func TestStoreUpdateDirTTL(t *testing.T) {
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
e, err := s.Update("/foo/bar", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) e, err := s.Update("/foo/bar", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.Node.Dir, false) assert.Equal(t, e.Node.Dir, false)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
e, _ = s.Get("/foo/bar", false, false) e, _ = s.Get("/foo/bar", false, false)
testutil.AssertEqual(t, *e.Node.Value, "") assert.Equal(t, *e.Node.Value, "")
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
fc.Advance(600 * time.Millisecond) fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
e, err = s.Get("/foo/bar", false, false) e, err = s.Get("/foo/bar", false, false)
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
testutil.AssertEqual(t, err.(*v2error.Error).ErrorCode, v2error.EcodeKeyNotFound) assert.Equal(t, err.(*v2error.Error).ErrorCode, v2error.EcodeKeyNotFound)
} }
// Ensure that the store can watch for key expiration. // Ensure that the store can watch for key expiration.
@ -151,7 +152,7 @@ func TestStoreWatchExpire(t *testing.T) {
s.Create("/foodir", true, "", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) s.Create("/foodir", true, "", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
w, _ := s.Watch("/", true, false, 0) w, _ := s.Watch("/", true, false, 0)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
c := w.EventChan() c := w.EventChan()
e := nbselect(c) e := nbselect(c)
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
@ -159,22 +160,22 @@ func TestStoreWatchExpire(t *testing.T) {
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
eidx = 4 eidx = 4
e = nbselect(c) e = nbselect(c)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "expire") assert.Equal(t, e.Action, "expire")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
w, _ = s.Watch("/", true, false, 5) w, _ = s.Watch("/", true, false, 5)
eidx = 6 eidx = 6
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
e = nbselect(w.EventChan()) e = nbselect(w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "expire") assert.Equal(t, e.Action, "expire")
testutil.AssertEqual(t, e.Node.Key, "/foofoo") assert.Equal(t, e.Node.Key, "/foofoo")
w, _ = s.Watch("/", true, false, 6) w, _ = s.Watch("/", true, false, 6)
e = nbselect(w.EventChan()) e = nbselect(w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "expire") assert.Equal(t, e.Action, "expire")
testutil.AssertEqual(t, e.Node.Key, "/foodir") assert.Equal(t, e.Node.Key, "/foodir")
testutil.AssertEqual(t, e.Node.Dir, true) assert.Equal(t, e.Node.Dir, true)
} }
// Ensure that the store can watch for key expiration when refreshing. // Ensure that the store can watch for key expiration when refreshing.
@ -189,7 +190,7 @@ func TestStoreWatchExpireRefresh(t *testing.T) {
// Make sure we set watch updates when Refresh is true for newly created keys // Make sure we set watch updates when Refresh is true for newly created keys
w, _ := s.Watch("/", true, false, 0) w, _ := s.Watch("/", true, false, 0)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
c := w.EventChan() c := w.EventChan()
e := nbselect(c) e := nbselect(c)
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
@ -197,20 +198,20 @@ func TestStoreWatchExpireRefresh(t *testing.T) {
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
eidx = 3 eidx = 3
e = nbselect(c) e = nbselect(c)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "expire") assert.Equal(t, e.Action, "expire")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
s.Update("/foofoo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true}) s.Update("/foofoo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
w, _ = s.Watch("/", true, false, 4) w, _ = s.Watch("/", true, false, 4)
fc.Advance(700 * time.Millisecond) fc.Advance(700 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
eidx = 5 // We should skip 4 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true eidx = 5 // We should skip 4 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true
testutil.AssertEqual(t, w.StartIndex(), eidx-1) assert.Equal(t, w.StartIndex(), eidx-1)
e = nbselect(w.EventChan()) e = nbselect(w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "expire") assert.Equal(t, e.Action, "expire")
testutil.AssertEqual(t, e.Node.Key, "/foofoo") assert.Equal(t, e.Node.Key, "/foofoo")
} }
// Ensure that the store can watch for key expiration when refreshing with an empty value. // Ensure that the store can watch for key expiration when refreshing with an empty value.
@ -230,12 +231,12 @@ func TestStoreWatchExpireEmptyRefresh(t *testing.T) {
fc.Advance(700 * time.Millisecond) fc.Advance(700 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
eidx = 3 // We should skip 2 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true eidx = 3 // We should skip 2 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true
testutil.AssertEqual(t, w.StartIndex(), eidx-1) assert.Equal(t, w.StartIndex(), eidx-1)
e := nbselect(w.EventChan()) e := nbselect(w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "expire") assert.Equal(t, e.Action, "expire")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
} }
// Update TTL of a key (set TTLOptionSet.Refresh to false) and send notification // Update TTL of a key (set TTLOptionSet.Refresh to false) and send notification
@ -256,12 +257,12 @@ func TestStoreWatchNoRefresh(t *testing.T) {
fc.Advance(700 * time.Millisecond) fc.Advance(700 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
eidx = 2 eidx = 2
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
e := nbselect(w.EventChan()) e := nbselect(w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "update") assert.Equal(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
} }
// Ensure that the store can update the TTL on a value with refresh. // Ensure that the store can update the TTL on a value with refresh.
@ -312,8 +313,8 @@ func TestStoreRecoverWithExpiration(t *testing.T) {
e, err := s.Get("/foo/x", false, false) e, err := s.Get("/foo/x", false, false)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
e, err = s.Get("/foo/y", false, false) e, err = s.Get("/foo/y", false, false)
testutil.AssertNotNil(t, err) testutil.AssertNotNil(t, err)
@ -340,8 +341,8 @@ func TestStoreWatchExpireWithHiddenKey(t *testing.T) {
fc.Advance(600 * time.Millisecond) fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now()) s.DeleteExpiredKeys(fc.Now())
e = nbselect(c) e = nbselect(c)
testutil.AssertEqual(t, e.Action, "expire") assert.Equal(t, e.Action, "expire")
testutil.AssertEqual(t, e.Node.Key, "/foofoo") assert.Equal(t, e.Node.Key, "/foofoo")
} }
// newFakeClock creates a new FakeClock that has been advanced to at least minExpireTime // newFakeClock creates a new FakeClock that has been advanced to at least minExpireTime

View File

@ -353,6 +353,7 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

View File

@ -23,8 +23,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/client/pkg/v3/testutil" "go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/client/v3" clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency" "go.etcd.io/etcd/client/v3/concurrency"
"go.etcd.io/etcd/client/v3/leasing" "go.etcd.io/etcd/client/v3/leasing"
"go.etcd.io/etcd/tests/v3/integration" "go.etcd.io/etcd/tests/v3/integration"
@ -209,14 +210,14 @@ func TestLeasingGetNoLeaseTTL(t *testing.T) {
gresp, err := lkv.Get(context.TODO(), "k") gresp, err := lkv.Get(context.TODO(), "k")
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, len(gresp.Kvs), 1) assert.Equal(t, len(gresp.Kvs), 1)
clus.Members[0].Stop(t) clus.Members[0].Stop(t)
ctx, cancel := context.WithTimeout(context.TODO(), time.Second) ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
_, err = lkv.Get(ctx, "k") _, err = lkv.Get(ctx, "k")
cancel() cancel()
testutil.AssertEqual(t, err, ctx.Err()) assert.Equal(t, err, ctx.Err())
} }
// TestLeasingGetSerializable checks the leasing KV can make serialized requests // TestLeasingGetSerializable checks the leasing KV can make serialized requests

View File

@ -20,6 +20,7 @@ package v2store_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/client/pkg/v3/testutil" "go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/server/v3/etcdserver/api/v2store" "go.etcd.io/etcd/server/v3/etcdserver/api/v2store"
"go.etcd.io/etcd/tests/v3/integration" "go.etcd.io/etcd/tests/v3/integration"
@ -55,14 +56,14 @@ func TestStoreRecover(t *testing.T) {
s2.Recovery(b) s2.Recovery(b)
e, err := s.Get("/foo/x", false, false) e, err := s.Get("/foo/x", false, false)
testutil.AssertEqual(t, e.Node.CreatedIndex, uint64(2)) assert.Equal(t, e.Node.CreatedIndex, uint64(2))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3)) assert.Equal(t, e.Node.ModifiedIndex, uint64(3))
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, *e.Node.Value, "barbar") assert.Equal(t, *e.Node.Value, "barbar")
e, err = s.Get("/foo/y", false, false) e, err = s.Get("/foo/y", false, false)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
} }

View File

@ -19,6 +19,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/client/pkg/v3/testutil" "go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/server/v3/etcdserver/api/v2error" "go.etcd.io/etcd/server/v3/etcdserver/api/v2error"
"go.etcd.io/etcd/server/v3/etcdserver/api/v2store" "go.etcd.io/etcd/server/v3/etcdserver/api/v2store"
@ -48,10 +49,10 @@ func TestStoreGetValue(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
e, err := s.Get("/foo", false, false) e, err := s.Get("/foo", false, false)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "get") assert.Equal(t, e.Action, "get")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
} }
// Ensure that the store can retrieve a directory in sorted order. // Ensure that the store can retrieve a directory in sorted order.
@ -68,7 +69,7 @@ func TestStoreGetSorted(t *testing.T) {
var eidx uint64 = 6 var eidx uint64 = 6
e, err := s.Get("/foo", true, true) e, err := s.Get("/foo", true, true)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
var yNodes v2store.NodeExterns var yNodes v2store.NodeExterns
sortedStrings := []string{"/foo/x", "/foo/y", "/foo/z"} sortedStrings := []string{"/foo/x", "/foo/y", "/foo/z"}
@ -99,79 +100,79 @@ func TestSet(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
e, err := s.Set("/foo", false, "", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err := s.Set("/foo", false, "", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "set") assert.Equal(t, e.Action, "set")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "") assert.Equal(t, *e.Node.Value, "")
testutil.AssertNil(t, e.Node.Nodes) testutil.AssertNil(t, e.Node.Nodes)
testutil.AssertNil(t, e.Node.Expiration) testutil.AssertNil(t, e.Node.Expiration)
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(1)) assert.Equal(t, e.Node.ModifiedIndex, uint64(1))
// Set /foo="bar" // Set /foo="bar"
eidx = 2 eidx = 2
e, err = s.Set("/foo", false, "bar", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err = s.Set("/foo", false, "bar", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "set") assert.Equal(t, e.Action, "set")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
testutil.AssertNil(t, e.Node.Nodes) testutil.AssertNil(t, e.Node.Nodes)
testutil.AssertNil(t, e.Node.Expiration) testutil.AssertNil(t, e.Node.Expiration)
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2)) assert.Equal(t, e.Node.ModifiedIndex, uint64(2))
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "") assert.Equal(t, *e.PrevNode.Value, "")
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1))
// Set /foo="baz" (for testing prevNode) // Set /foo="baz" (for testing prevNode)
eidx = 3 eidx = 3
e, err = s.Set("/foo", false, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err = s.Set("/foo", false, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "set") assert.Equal(t, e.Action, "set")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
testutil.AssertNil(t, e.Node.Nodes) testutil.AssertNil(t, e.Node.Nodes)
testutil.AssertNil(t, e.Node.Expiration) testutil.AssertNil(t, e.Node.Expiration)
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3)) assert.Equal(t, e.Node.ModifiedIndex, uint64(3))
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(2)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(2))
// Set /a/b/c/d="efg" // Set /a/b/c/d="efg"
eidx = 4 eidx = 4
e, err = s.Set("/a/b/c/d", false, "efg", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err = s.Set("/a/b/c/d", false, "efg", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Node.Key, "/a/b/c/d") assert.Equal(t, e.Node.Key, "/a/b/c/d")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "efg") assert.Equal(t, *e.Node.Value, "efg")
testutil.AssertNil(t, e.Node.Nodes) testutil.AssertNil(t, e.Node.Nodes)
testutil.AssertNil(t, e.Node.Expiration) testutil.AssertNil(t, e.Node.Expiration)
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(4)) assert.Equal(t, e.Node.ModifiedIndex, uint64(4))
// Set /dir as a directory // Set /dir as a directory
eidx = 5 eidx = 5
e, err = s.Set("/dir", true, "", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err = s.Set("/dir", true, "", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "set") assert.Equal(t, e.Action, "set")
testutil.AssertEqual(t, e.Node.Key, "/dir") assert.Equal(t, e.Node.Key, "/dir")
testutil.AssertTrue(t, e.Node.Dir) testutil.AssertTrue(t, e.Node.Dir)
testutil.AssertNil(t, e.Node.Value) testutil.AssertNil(t, e.Node.Value)
testutil.AssertNil(t, e.Node.Nodes) testutil.AssertNil(t, e.Node.Nodes)
testutil.AssertNil(t, e.Node.Expiration) testutil.AssertNil(t, e.Node.Expiration)
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(5)) assert.Equal(t, e.Node.ModifiedIndex, uint64(5))
} }
// Ensure that the store can create a new key if it doesn't already exist. // Ensure that the store can create a new key if it doesn't already exist.
@ -183,29 +184,29 @@ func TestStoreCreateValue(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
e, err := s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err := s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
testutil.AssertNil(t, e.Node.Nodes) testutil.AssertNil(t, e.Node.Nodes)
testutil.AssertNil(t, e.Node.Expiration) testutil.AssertNil(t, e.Node.Expiration)
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(1)) assert.Equal(t, e.Node.ModifiedIndex, uint64(1))
// Create /empty="" // Create /empty=""
eidx = 2 eidx = 2
e, err = s.Create("/empty", false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err = s.Create("/empty", false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/empty") assert.Equal(t, e.Node.Key, "/empty")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "") assert.Equal(t, *e.Node.Value, "")
testutil.AssertNil(t, e.Node.Nodes) testutil.AssertNil(t, e.Node.Nodes)
testutil.AssertNil(t, e.Node.Expiration) testutil.AssertNil(t, e.Node.Expiration)
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2)) assert.Equal(t, e.Node.ModifiedIndex, uint64(2))
} }
@ -217,9 +218,9 @@ func TestStoreCreateDirectory(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
e, err := s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err := s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertTrue(t, e.Node.Dir) testutil.AssertTrue(t, e.Node.Dir)
} }
@ -234,10 +235,10 @@ func TestStoreCreateFailsIfExists(t *testing.T) {
// create /foo as dir again // create /foo as dir again
e, _err := s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, _err := s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeNodeExist) assert.Equal(t, err.ErrorCode, v2error.EcodeNodeExist)
testutil.AssertEqual(t, err.Message, "Key already exists") assert.Equal(t, err.Message, "Key already exists")
testutil.AssertEqual(t, err.Cause, "/foo") assert.Equal(t, err.Cause, "/foo")
testutil.AssertEqual(t, err.Index, uint64(1)) assert.Equal(t, err.Index, uint64(1))
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
} }
@ -252,43 +253,43 @@ func TestStoreUpdateValue(t *testing.T) {
var eidx uint64 = 2 var eidx uint64 = 2
e, err := s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err := s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "update") assert.Equal(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2)) assert.Equal(t, e.Node.ModifiedIndex, uint64(2))
// check prevNode // check prevNode
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
testutil.AssertEqual(t, e.PrevNode.TTL, int64(0)) assert.Equal(t, e.PrevNode.TTL, int64(0))
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1))
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
// update /foo="" // update /foo=""
eidx = 3 eidx = 3
e, err = s.Update("/foo", "", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err = s.Update("/foo", "", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "update") assert.Equal(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertFalse(t, e.Node.Dir) testutil.AssertFalse(t, e.Node.Dir)
testutil.AssertEqual(t, *e.Node.Value, "") assert.Equal(t, *e.Node.Value, "")
testutil.AssertEqual(t, e.Node.TTL, int64(0)) assert.Equal(t, e.Node.TTL, int64(0))
testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3)) assert.Equal(t, e.Node.ModifiedIndex, uint64(3))
// check prevNode // check prevNode
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "baz") assert.Equal(t, *e.PrevNode.Value, "baz")
testutil.AssertEqual(t, e.PrevNode.TTL, int64(0)) assert.Equal(t, e.PrevNode.TTL, int64(0))
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(2)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(2))
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, *e.Node.Value, "") assert.Equal(t, *e.Node.Value, "")
} }
// Ensure that the store cannot update a directory. // Ensure that the store cannot update a directory.
@ -299,9 +300,9 @@ func TestStoreUpdateFailsIfDirectory(t *testing.T) {
s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, _err := s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, _err := s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeNotFile) assert.Equal(t, err.ErrorCode, v2error.EcodeNotFile)
testutil.AssertEqual(t, err.Message, "Not a file") assert.Equal(t, err.Message, "Not a file")
testutil.AssertEqual(t, err.Cause, "/foo") assert.Equal(t, err.Cause, "/foo")
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
} }
@ -314,12 +315,12 @@ func TestStoreDeleteValue(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, err := s.Delete("/foo", false, false) e, err := s.Delete("/foo", false, false)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "delete") assert.Equal(t, e.Action, "delete")
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
} }
// Ensure that the store can delete a directory if recursive is specified. // Ensure that the store can delete a directory if recursive is specified.
@ -334,12 +335,12 @@ func TestStoreDeleteDirectory(t *testing.T) {
// this should succeed, since the directory is empty // this should succeed, since the directory is empty
e, err := s.Delete("/foo", true, false) e, err := s.Delete("/foo", true, false)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "delete") assert.Equal(t, e.Action, "delete")
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, e.PrevNode.Dir, true) assert.Equal(t, e.PrevNode.Dir, true)
// create directory /foo and directory /foo/bar // create directory /foo and directory /foo/bar
_, err = s.Create("/foo/bar", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) _, err = s.Create("/foo/bar", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
@ -355,7 +356,7 @@ func TestStoreDeleteDirectory(t *testing.T) {
// items under the given directory // items under the given directory
e, err = s.Delete("/foo", false, true) e, err = s.Delete("/foo", false, true)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.Action, "delete") assert.Equal(t, e.Action, "delete")
} }
@ -368,8 +369,8 @@ func TestStoreDeleteDirectoryFailsIfNonRecursiveAndDir(t *testing.T) {
s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", true, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, _err := s.Delete("/foo", false, false) e, _err := s.Delete("/foo", false, false)
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeNotFile) assert.Equal(t, err.ErrorCode, v2error.EcodeNotFile)
testutil.AssertEqual(t, err.Message, "Not a file") assert.Equal(t, err.Message, "Not a file")
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
} }
@ -403,16 +404,16 @@ func TestStoreCompareAndDeletePrevValue(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, err := s.CompareAndDelete("/foo", "bar", 0) e, err := s.CompareAndDelete("/foo", "bar", 0)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "compareAndDelete") assert.Equal(t, e.Action, "compareAndDelete")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1))
testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1))
} }
func TestStoreCompareAndDeletePrevValueFailsIfNotMatch(t *testing.T) { func TestStoreCompareAndDeletePrevValueFailsIfNotMatch(t *testing.T) {
@ -423,12 +424,12 @@ func TestStoreCompareAndDeletePrevValueFailsIfNotMatch(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, _err := s.CompareAndDelete("/foo", "baz", 0) e, _err := s.CompareAndDelete("/foo", "baz", 0)
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeTestFailed) assert.Equal(t, err.ErrorCode, v2error.EcodeTestFailed)
testutil.AssertEqual(t, err.Message, "Compare failed") assert.Equal(t, err.Message, "Compare failed")
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
} }
func TestStoreCompareAndDeletePrevIndex(t *testing.T) { func TestStoreCompareAndDeletePrevIndex(t *testing.T) {
@ -439,14 +440,14 @@ func TestStoreCompareAndDeletePrevIndex(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, err := s.CompareAndDelete("/foo", "", 1) e, err := s.CompareAndDelete("/foo", "", 1)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "compareAndDelete") assert.Equal(t, e.Action, "compareAndDelete")
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1))
testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1))
} }
func TestStoreCompareAndDeletePrevIndexFailsIfNotMatch(t *testing.T) { func TestStoreCompareAndDeletePrevIndexFailsIfNotMatch(t *testing.T) {
@ -458,12 +459,12 @@ func TestStoreCompareAndDeletePrevIndexFailsIfNotMatch(t *testing.T) {
e, _err := s.CompareAndDelete("/foo", "", 100) e, _err := s.CompareAndDelete("/foo", "", 100)
testutil.AssertNotNil(t, _err) testutil.AssertNotNil(t, _err)
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeTestFailed) assert.Equal(t, err.ErrorCode, v2error.EcodeTestFailed)
testutil.AssertEqual(t, err.Message, "Compare failed") assert.Equal(t, err.Message, "Compare failed")
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
} }
// Ensure that the store cannot delete a directory. // Ensure that the store cannot delete a directory.
@ -475,7 +476,7 @@ func TestStoreCompareAndDeleteDirectoryFail(t *testing.T) {
_, _err := s.CompareAndDelete("/foo", "", 0) _, _err := s.CompareAndDelete("/foo", "", 0)
testutil.AssertNotNil(t, _err) testutil.AssertNotNil(t, _err)
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeNotFile) assert.Equal(t, err.ErrorCode, v2error.EcodeNotFile)
} }
// Ensure that the store can conditionally update a key if it has a previous value. // Ensure that the store can conditionally update a key if it has a previous value.
@ -487,18 +488,18 @@ func TestStoreCompareAndSwapPrevValue(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, err := s.CompareAndSwap("/foo", "bar", 0, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err := s.CompareAndSwap("/foo", "bar", 0, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "compareAndSwap") assert.Equal(t, e.Action, "compareAndSwap")
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1))
testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1))
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
} }
// Ensure that the store cannot conditionally update a key if it has the wrong previous value. // Ensure that the store cannot conditionally update a key if it has the wrong previous value.
@ -509,12 +510,12 @@ func TestStoreCompareAndSwapPrevValueFailsIfNotMatch(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, _err := s.CompareAndSwap("/foo", "wrong_value", 0, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, _err := s.CompareAndSwap("/foo", "wrong_value", 0, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeTestFailed) assert.Equal(t, err.ErrorCode, v2error.EcodeTestFailed)
testutil.AssertEqual(t, err.Message, "Compare failed") assert.Equal(t, err.Message, "Compare failed")
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
} }
// Ensure that the store can conditionally update a key if it has a previous index. // Ensure that the store can conditionally update a key if it has a previous index.
@ -525,19 +526,19 @@ func TestStoreCompareAndSwapPrevIndex(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, err := s.CompareAndSwap("/foo", "", 1, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, err := s.CompareAndSwap("/foo", "", 1, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "compareAndSwap") assert.Equal(t, e.Action, "compareAndSwap")
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
// check prevNode // check prevNode
testutil.AssertNotNil(t, e.PrevNode) testutil.AssertNotNil(t, e.PrevNode)
testutil.AssertEqual(t, e.PrevNode.Key, "/foo") assert.Equal(t, e.PrevNode.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar") assert.Equal(t, *e.PrevNode.Value, "bar")
testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1))
testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1))
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
} }
// Ensure that the store cannot conditionally update a key if it has the wrong previous index. // Ensure that the store cannot conditionally update a key if it has the wrong previous index.
@ -548,12 +549,12 @@ func TestStoreCompareAndSwapPrevIndexFailsIfNotMatch(t *testing.T) {
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e, _err := s.CompareAndSwap("/foo", "", 100, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) e, _err := s.CompareAndSwap("/foo", "", 100, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
err := _err.(*v2error.Error) err := _err.(*v2error.Error)
testutil.AssertEqual(t, err.ErrorCode, v2error.EcodeTestFailed) assert.Equal(t, err.ErrorCode, v2error.EcodeTestFailed)
testutil.AssertEqual(t, err.Message, "Compare failed") assert.Equal(t, err.Message, "Compare failed")
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
e, _ = s.Get("/foo", false, false) e, _ = s.Get("/foo", false, false)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
} }
// Ensure that the store can watch for key creation. // Ensure that the store can watch for key creation.
@ -563,13 +564,13 @@ func TestStoreWatchCreate(t *testing.T) {
var eidx uint64 = 0 var eidx uint64 = 0
w, _ := s.Watch("/foo", false, false, 0) w, _ := s.Watch("/foo", false, false, 0)
c := w.EventChan() c := w.EventChan()
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
eidx = 1 eidx = 1
e := timeoutSelect(t, c) e := timeoutSelect(t, c)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
select { select {
case e = <-w.EventChan(): case e = <-w.EventChan():
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
@ -584,13 +585,13 @@ func TestStoreWatchRecursiveCreate(t *testing.T) {
var eidx uint64 = 0 var eidx uint64 = 0
w, err := s.Watch("/foo", true, false, 0) w, err := s.Watch("/foo", true, false, 0)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
eidx = 1 eidx = 1
s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/foo/bar") assert.Equal(t, e.Node.Key, "/foo/bar")
} }
// Ensure that the store can watch for key updates. // Ensure that the store can watch for key updates.
@ -600,13 +601,13 @@ func TestStoreWatchUpdate(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
w, _ := s.Watch("/foo", false, false, 0) w, _ := s.Watch("/foo", false, false, 0)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
eidx = 2 eidx = 2
s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "update") assert.Equal(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
} }
// Ensure that the store can watch for recursive key updates. // Ensure that the store can watch for recursive key updates.
@ -617,13 +618,13 @@ func TestStoreWatchRecursiveUpdate(t *testing.T) {
s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
w, err := s.Watch("/foo", true, false, 0) w, err := s.Watch("/foo", true, false, 0)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
eidx = 2 eidx = 2
s.Update("/foo/bar", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Update("/foo/bar", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "update") assert.Equal(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/foo/bar") assert.Equal(t, e.Node.Key, "/foo/bar")
} }
// Ensure that the store can watch for key deletions. // Ensure that the store can watch for key deletions.
@ -633,13 +634,13 @@ func TestStoreWatchDelete(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
w, _ := s.Watch("/foo", false, false, 0) w, _ := s.Watch("/foo", false, false, 0)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
eidx = 2 eidx = 2
s.Delete("/foo", false, false) s.Delete("/foo", false, false)
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "delete") assert.Equal(t, e.Action, "delete")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
} }
// Ensure that the store can watch for recursive key deletions. // Ensure that the store can watch for recursive key deletions.
@ -650,13 +651,13 @@ func TestStoreWatchRecursiveDelete(t *testing.T) {
s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
w, err := s.Watch("/foo", true, false, 0) w, err := s.Watch("/foo", true, false, 0)
testutil.AssertNil(t, err) testutil.AssertNil(t, err)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
eidx = 2 eidx = 2
s.Delete("/foo/bar", false, false) s.Delete("/foo/bar", false, false)
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "delete") assert.Equal(t, e.Action, "delete")
testutil.AssertEqual(t, e.Node.Key, "/foo/bar") assert.Equal(t, e.Node.Key, "/foo/bar")
} }
// Ensure that the store can watch for CAS updates. // Ensure that the store can watch for CAS updates.
@ -666,13 +667,13 @@ func TestStoreWatchCompareAndSwap(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
w, _ := s.Watch("/foo", false, false, 0) w, _ := s.Watch("/foo", false, false, 0)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
eidx = 2 eidx = 2
s.CompareAndSwap("/foo", "bar", 0, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.CompareAndSwap("/foo", "bar", 0, "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "compareAndSwap") assert.Equal(t, e.Action, "compareAndSwap")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
} }
// Ensure that the store can watch for recursive CAS updates. // Ensure that the store can watch for recursive CAS updates.
@ -682,13 +683,13 @@ func TestStoreWatchRecursiveCompareAndSwap(t *testing.T) {
var eidx uint64 = 1 var eidx uint64 = 1
s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo/bar", false, "baz", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
w, _ := s.Watch("/foo", true, false, 0) w, _ := s.Watch("/foo", true, false, 0)
testutil.AssertEqual(t, w.StartIndex(), eidx) assert.Equal(t, w.StartIndex(), eidx)
eidx = 2 eidx = 2
s.CompareAndSwap("/foo/bar", "baz", 0, "bat", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.CompareAndSwap("/foo/bar", "baz", 0, "bat", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "compareAndSwap") assert.Equal(t, e.Action, "compareAndSwap")
testutil.AssertEqual(t, e.Node.Key, "/foo/bar") assert.Equal(t, e.Node.Key, "/foo/bar")
} }
// Ensure that the store can watch in streaming mode. // Ensure that the store can watch in streaming mode.
@ -700,10 +701,10 @@ func TestStoreWatchStream(t *testing.T) {
// first modification // first modification
s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, *e.Node.Value, "bar") assert.Equal(t, *e.Node.Value, "bar")
select { select {
case e = <-w.EventChan(): case e = <-w.EventChan():
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
@ -713,10 +714,10 @@ func TestStoreWatchStream(t *testing.T) {
eidx = 2 eidx = 2
s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Update("/foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e = timeoutSelect(t, w.EventChan()) e = timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "update") assert.Equal(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/foo") assert.Equal(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, *e.Node.Value, "baz") assert.Equal(t, *e.Node.Value, "baz")
select { select {
case e = <-w.EventChan(): case e = <-w.EventChan():
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
@ -732,9 +733,9 @@ func TestStoreWatchCreateWithHiddenKey(t *testing.T) {
w, _ := s.Watch("/_foo", false, false, 0) w, _ := s.Watch("/_foo", false, false, 0)
s.Create("/_foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Create("/_foo", false, "bar", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/_foo") assert.Equal(t, e.Node.Key, "/_foo")
select { select {
case e = <-w.EventChan(): case e = <-w.EventChan():
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
@ -773,8 +774,8 @@ func TestStoreWatchUpdateWithHiddenKey(t *testing.T) {
w, _ := s.Watch("/_foo", false, false, 0) w, _ := s.Watch("/_foo", false, false, 0)
s.Update("/_foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) s.Update("/_foo", "baz", v2store.TTLOptionSet{ExpireTime: v2store.Permanent})
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.Action, "update") assert.Equal(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/_foo") assert.Equal(t, e.Node.Key, "/_foo")
e = nbselect(w.EventChan()) e = nbselect(w.EventChan())
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
} }
@ -799,9 +800,9 @@ func TestStoreWatchDeleteWithHiddenKey(t *testing.T) {
w, _ := s.Watch("/_foo", false, false, 0) w, _ := s.Watch("/_foo", false, false, 0)
s.Delete("/_foo", false, false) s.Delete("/_foo", false, false)
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "delete") assert.Equal(t, e.Action, "delete")
testutil.AssertEqual(t, e.Node.Key, "/_foo") assert.Equal(t, e.Node.Key, "/_foo")
e = nbselect(w.EventChan()) e = nbselect(w.EventChan())
testutil.AssertNil(t, e) testutil.AssertNil(t, e)
} }
@ -827,9 +828,9 @@ func TestStoreWatchRecursiveCreateDeeperThanHiddenKey(t *testing.T) {
e := timeoutSelect(t, w.EventChan()) e := timeoutSelect(t, w.EventChan())
testutil.AssertNotNil(t, e) testutil.AssertNotNil(t, e)
testutil.AssertEqual(t, e.EtcdIndex, eidx) assert.Equal(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "create") assert.Equal(t, e.Action, "create")
testutil.AssertEqual(t, e.Node.Key, "/_foo/bar/baz") assert.Equal(t, e.Node.Key, "/_foo/bar/baz")
} }
// Ensure that slow consumers are handled properly. // Ensure that slow consumers are handled properly.
@ -847,10 +848,10 @@ func TestStoreWatchSlowConsumer(t *testing.T) {
for i := 1; i <= 100; i++ { for i := 1; i <= 100; i++ {
s.Set("/foo", false, fmt.Sprint(i), v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // ok s.Set("/foo", false, fmt.Sprint(i), v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // ok
} }
// testutil.AssertEqual(t, s.WatcherHub.count, int64(1)) // assert.Equal(t, s.WatcherHub.count, int64(1))
s.Set("/foo", false, "101", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // ok s.Set("/foo", false, "101", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // ok
// remove watcher // remove watcher
// testutil.AssertEqual(t, s.WatcherHub.count, int64(0)) // assert.Equal(t, s.WatcherHub.count, int64(0))
s.Set("/foo", false, "102", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // must not panic s.Set("/foo", false, "102", v2store.TTLOptionSet{ExpireTime: v2store.Permanent}) // must not panic
} }