From 22745169b3287d8831a2119cf0ddbc27fb3f2bc7 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 18 Nov 2019 10:56:33 -0700 Subject: Add script to update test fixtures --- bin/update-test-fixtures | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bin/update-test-fixtures diff --git a/bin/update-test-fixtures b/bin/update-test-fixtures new file mode 100755 index 0000000..380192f --- /dev/null +++ b/bin/update-test-fixtures @@ -0,0 +1,41 @@ +#!/bin/bash + +cd "$(dirname "$0")/.." + +root_dir=$(pwd) +tmp_dir=$root_dir/tmp +branch='update-test-fixtures' +mkdir -p "$tmp_dir" + +projects=$(ls test/results/ | sed -e 's/-v.*\.json//p' | sort | uniq) +echo $projects +for project in ${projects[@]}; do + echo "$project" + cd "$tmp_dir" + rm -fr "$project" + git clone "git@gitlab.com:gitlab-org/security-products/tests/$project.git" + cd "$project" + DIFF=$(diff "$root_dir/test/results/$project-v2.json" qa/expect/gl-license-management-report.json) + + if [[ $DIFF = "" ]]; then + continue + fi + + git co -b $branch + cp "$root_dir/test/results/$project-v2.json" qa/expect/gl-license-management-report.json + git diff + printf "Commit? (y/n)" + read -r answer + case $answer in + [Yy]* ) + git commit -am 'Update test fixture' + printf "Push? (y/n)" + read -r answer + case $answer in + [Yy]* ) git push -f origin $branch;; + [Nn]* ) echo 'Skipping commit';; + esac + ;; + [Nn]* ) echo 'Skipping commit';; + esac +done -- cgit v1.2.3