One approach is to load names into an indexed array and then use another loop to rename the files using the array:-
#!/bin/ksh
# Load names into an indexed array
c=1
while read file
do
A_fname[$c]="$file"
(( ++c ))
done < names.txt
# Rename *.test files using array value
c=1
for file in *.test
do
if [ ! -z ${A_fname[$c]} ]
then
print "mv ${file} ${file%%-*}-${A_fname[$c]}.test"
(( ++c ))
fi
done
Remove the highlighted print and rerun if the output looks good.