testcase for patch empty field

This commit is contained in:
Olof hagsand 2021-06-28 22:43:33 +02:00
parent 54357a2a78
commit 96c9296056
2 changed files with 15 additions and 4 deletions

View file

@ -167,7 +167,6 @@ cat<<EOF > $startupdb
EOF EOF
new "kill old restconf" new "kill old restconf"
sleep $DEMSLEEP
stop_restconf_pre stop_restconf_pre
new "test params: -f $cfg" new "test params: -f $cfg"
@ -276,9 +275,8 @@ if [ $pid0 -eq $pid3 ]; then
err1 "A different pid" "same pid: $pid3" err1 "A different pid" "same pid: $pid3"
fi fi
new "kill restconf using kill" new "kill restconf"
sleep $DEMSLEEP sudo kill $pid3
stop_restconf_pre
new "Wait for restconf to stop" new "Wait for restconf to stop"
wait_restconf_stopped wait_restconf_stopped

View file

@ -91,6 +91,9 @@ cat <<EOF > $dir/example-system.yang
leaf enable-jukebox-streaming { leaf enable-jukebox-streaming {
type boolean; type boolean;
} }
leaf extraleaf {
type string;
}
} }
} }
EOF EOF
@ -250,6 +253,16 @@ expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H "Content-Type: application
new "GET check" # XXX: "data" should probably be namespaced? new "GET check" # XXX: "data" should probably be namespaced?
expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data?content=config -H 'Accept: application/yang-data+xml')" 0 "HTTP/$HVER 200" '<extra xmlns="http://example.com/ns/example-jukebox">c</extra>' '<data>' expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data?content=config -H 'Accept: application/yang-data+xml')" 0 "HTTP/$HVER 200" '<extra xmlns="http://example.com/ns/example-jukebox">c</extra>' '<data>'
new "Add empty leaf"
expectpart "$(curl -u andy:bar $CURLOPTS -X POST $RCPROTO://localhost/restconf/data -H 'Content-Type: application/yang-data+json' -d '{"example-system:system":{"extraleaf":""}}')" 0 "HTTP/$HVER 201"
new "Add entry with PATCH"
expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH $RCPROTO://localhost/restconf/data/example-system:system -H 'Content-Type: application/yang-data+json' -d '{"example-system:system":{"extraleaf":"something"}}')" 0 "HTTP/$HVER 204"
new "GET check"
expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example-system:system -H 'Accept: application/yang-data+xml')" 0 "HTTP/$HVER 200" '<system xmlns="http://example.com/ns/example-system"><extraleaf>something</extraleaf></system>'
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "Kill restconf daemon" new "Kill restconf daemon"
stop_restconf stop_restconf