Skip to content

Commit

Permalink
t/kvs: Add kvs --append tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chu11 committed Oct 31, 2017
1 parent 2dec83b commit 0145b56
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions t/t1000-kvs.t
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,73 @@ test_expect_success 'kvs: treeobj can be used to create snapshot' '
test_cmp snap.expected snap.actual
'

#
# append tests
#
test_expect_success 'kvs: append on non-existent key is same as create' '
flux kvs unlink -Rf $DIR &&
flux kvs put --append $DIR.a=abc &&
printf "%s\n" "abc" >expected &&
flux kvs get $DIR.a >output &&
test_cmp output expected
'

test_expect_success 'kvs: basic append works' '
flux kvs unlink -Rf $DIR &&
flux kvs put $DIR.a=abc &&
flux kvs put --append $DIR.a=def &&
flux kvs put --append $DIR.a=ghi &&
printf "%s%s%s\n" "abcdefghi" >expected &&
flux kvs get $DIR.a >output &&
test_cmp output expected
'

test_expect_success 'kvs: basic append works with --raw' '
flux kvs unlink -Rf $DIR &&
flux kvs put --raw $DIR.a=abc &&
flux kvs put --append --raw $DIR.a=def &&
flux kvs put --append --raw $DIR.a=ghi &&
printf "%s" "abcdefghi" >expected &&
flux kvs get --raw $DIR.a >output &&
test_cmp output expected
'

test_expect_success 'kvs: basic append works with newlines' '
flux kvs unlink -Rf $DIR &&
echo "abc" | flux kvs put --raw $DIR.a=- &&
echo "def" | flux kvs put --append --raw $DIR.a=- &&
echo "ghi" | flux kvs put --append --raw $DIR.a=- &&
printf "%s\n%s\n%s\n" "abc" "def" "ghi" >expected &&
flux kvs get --raw $DIR.a >output &&
test_cmp output expected
'

test_expect_success 'kvs: append to zero length value works' '
flux kvs unlink -Rf $DIR &&
flux kvs put $DIR.a= &&
flux kvs put --append $DIR.a=abc &&
printf "%s\n" "abc" >expected &&
flux kvs get $DIR.a >output &&
test_cmp output expected
'

test_expect_success 'kvs: append a zero length value works' '
flux kvs unlink -Rf $DIR &&
flux kvs put $DIR.a=abc &&
flux kvs put --append $DIR.a= &&
printf "%s\n" "abc" >expected &&
flux kvs get $DIR.a >output &&
test_cmp output expected
'

test_expect_success 'kvs: append a zero length value to zero length value works' '
flux kvs unlink -Rf $DIR &&
flux kvs put $DIR.a= &&
flux kvs put --append $DIR.a= &&
flux kvs get $DIR.a >empty.output &&
test_cmp /dev/null empty.output
'

#
# get corner case tests
#
Expand Down

0 comments on commit 0145b56

Please sign in to comment.