push-basic.sh 2.18 KB
Newer Older
1
#!/usr/bin/env bash
2

3 4 5 6
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
set -e

. ./test-lib.sh

setup_initgit
setup_gitgit

(
  set -e
  cd git-git
  git checkout -q --track -b work origin
  echo "some work done on a branch" >> test
  git add test; git commit -q -m "branch work"
  echo "some other work done on a branch" >> test
  git add test; git commit -q -m "branch work"

  test_expect_success "git-cl upload wants a server" \
24
    "$GIT_CL upload --no-oauth2 2>&1 | grep -q 'You must configure'"
25

26
  git config rietveld.server localhost:10000
27

28
  # echo $($GIT_CL_STATUS)
29
  test_expect_success "git-cl status has no issue" \
30
    "$GIT_CL_STATUS | grep -q 'No issue assigned'"
31 32

  # Prevent the editor from coming up when you upload.
33
  export GIT_EDITOR=$(which true)
34
  test_expect_success "upload succeeds (needs a server running on localhost)" \
35
    "$GIT_CL upload  --no-oauth2  -m test master | grep -q 'Issue created'"
36 37

  test_expect_success "git-cl status now knows the issue" \
38
    "$GIT_CL_STATUS | grep -q 'Issue number'"
39 40

  # Push a description to this URL.
41
  URL=$($GIT_CL_STATUS | sed -ne '/Issue number/s/[^(]*(\(.*\))/\1/p')
42 43 44 45 46 47
  curl --cookie dev_appserver_login="test@example.com:False" \
       --data-urlencode subject="test" \
       --data-urlencode description="foo-quux" \
       --data-urlencode xsrf_token="$(print_xsrf_token)" \
       $URL/edit

48
  API=$(echo $URL | sed -e 's/\([0-9]\+\)$/api\/\1/')
49
  test_expect_success "Base URL contains branch name" \
50
      "curl -s $API | python -mjson.tool | grep base_url | grep -q '@master'"
51

52
  test_expect_success "git-cl land ok" \
53
    "$GIT_CL land -f --no-oauth2"
54 55 56 57 58 59 60 61

  git checkout -q master > /dev/null 2>&1
  git pull -q > /dev/null 2>&1

  test_expect_success "committed code has proper description" \
      "git show | grep -q 'foo-quux'"

  test_expect_success "issue no longer has a branch" \
62
      "$GIT_CL_STATUS | grep -q 'work : None'"
63 64 65 66 67 68 69 70 71 72 73 74

  cd $GITREPO_PATH
  test_expect_success "upstream repo has our commit" \
      "git log master 2>/dev/null | grep -q 'foo-quux'"
)
SUCCESS=$?

cleanup

if [ $SUCCESS == 0 ]; then
  echo PASS
fi