summaryrefslogtreecommitdiff
path: root/bin/update-test-fixtures
blob: 380192f025b113ddd0eb20178df63be1ef43c545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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