Merge branch '0.2' of https://github.com/coreos/etcd into v2-handler-tests

Conflicts:
	test.sh
This commit is contained in:
Ben Johnson
2013-10-18 08:54:51 -06:00
3 changed files with 31 additions and 16 deletions

View File

@@ -30,13 +30,21 @@ func SetKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
// If the "prevValue" is specified then test-and-set. Otherwise create a new key.
var c raft.Command
if prevValueArr, ok := req.Form["prevValue"]; ok && len(prevValueArr) > 0 {
if prevValueArr, ok := req.Form["prevValue"]; ok {
if len(prevValueArr[0]) > 0 { // test against previous value
c = &store.CompareAndSwapCommand{
Key: key,
Value: value,
PrevValue: prevValueArr[0],
ExpireTime: expireTime,
}
} else {
c = &store.CreateCommand{ // test against existence
Key: key,
Value: value,
ExpireTime: expireTime,
}
}
} else {
c = &store.SetCommand{

View File

@@ -55,13 +55,16 @@ func (event *Event) Response() interface{} {
Expiration: event.Expiration,
}
if response.Action == Create || response.Action == Set {
response.Action = "set"
if response.Action == Set {
if response.PrevValue == "" {
response.NewKey = true
}
}
if response.Action == CompareAndSwap || response.Action == Create {
response.Action = "testAndSet"
}
return response
} else {
responses := make([]*Response, len(event.KVPairs))

20
test.sh
View File

@@ -1,15 +1,19 @@
#!/bin/sh
set -e
# Unit tests
echo "-- UNIT TESTS --"
go test -v ./server/v2/tests
go test -v ./store
# Get GOPATH, etc from build
echo "-- BUILDING BINARY --"
. ./build
# use right GOPATH
export GOPATH="${PWD}"
# Unit tests
go test -i ./server/v2/tests
go test -v ./server/v2/tests
go test -i ./store
go test -v ./store
# Functional tests
echo "-- FUNCTIONAL TESTS --"
ETCD_BIN_PATH=$(PWD)/etcd go test -v ./tests/functional
go test -i ./tests/functional
ETCD_BIN_PATH=$(pwd)/etcd go test -v ./tests/functional