项目代码:
alias book_search="/usr/local/mysql/bin/mysql -h 172.18.12.202 -uppstat -pstatpp book_search"
echo "select id,cpname from search_cp_infomation where hide=1;" | book_search -s > $cpFile
使用打桩代码
alias book_search="/home/lishujun/src/mockobject/book_search"
echo "select id,cpname from search_cp_infomation where hide=1;" | book_search -s > $cpFile

预置的桩 book_search 通过标准输出打印出从12.208上拿回的真实数据,这样程序可以暂时在没有数据库的情况下执行逻辑,目前打桩之后程序可以运行

 
桩代码:
#!/bin/bash

sql="select id,cpname from search_cp_infomation where hide=1;"

while read line
do
#echo "$line"
if [ "$line" == "$sql" ] ; then
cat "/home/lishujun/src/mockobject/cplist"
fi
done
05-07 15:49