git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 14/15] git-note: (Tests) Add tests for git-note and associated functionality

From
Johan Herland <johan@herland.net>
Date
May 27, 2007, 14:16 UTC
Message-ID
<200705271616.53832.johan@herland.net>
In-Reply-To
<200705271608.02122.johan@herland.net>
This test script add tests for:
- git-note (including -l and -d options)
- State of note/tag objects
- git-show-ref --notes
- git-for-each-ref refs/notes
- git-{log,show,whatchanged} --decorate
Signed-off-by: Johan Herland <johan@herland.net>
---
 t/t3850-note.sh |  303 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 303 insertions(+), 0 deletions(-)
 create mode 100755 t/t3850-note.sh
diff --git a/t/t3850-note.sh b/t/t3850-note.sh
new file mode 100755
index 0000000..f737f7c
--- /dev/null
+++ b/t/t3850-note.sh
@@ -0,0 +1,303 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Johan Herland
+#
+
+test_description='Test of git-note'
+
+. ./test-lib.sh
+
+
+# Prepare repo and create some notes
+
+test_expect_success 'Preparing for test' '
+	echo "foo" > foo &&
+	git-add foo &&
+	test_tick &&
+	git-commit -m "Initial commit" &&
+	echo "bar" >> foo
+	test_tick &&
+	git-commit -m "Second commit" foo
+'
+test_expect_success 'Testing git-note -m' '
+	test_tick &&
+	git-note -m "spam"
+'
+test_expect_success 'Testing git-note -F' '
+	echo "spam spam" > note.msg &&
+	test_tick &&
+	git-note -F note.msg
+'
+test_expect_success 'Testing git-note <commit>' '
+	test_tick &&
+	git-note -m "spam spam spam" 301711b66fe71164f646b798706a2c1f7024da8d
+'
+
+# At this point we should have:
+# - commit @ 301711b66fe71164f646b798706a2c1f7024da8d ("Initial commit")
+#   - note @ 93bbbc95a42852552494327537263d475aac1789 ("spam spam spam")
+# - commit @ 9671cbee7ad26528645b2665c8f74d39a6288864 ("Second commit")
+#   - note @ 1245491fece5910086bc1870a4a746256f8a7ecf ("spam")
+#   - note @ 466f861dde008d3905d320225eebef727665a3f0 ("spam spam")
+
+# Verify note objects
+
+test_expect_success 'Testing git-cat-file tag <note>' '
+	cat > note.expect << EOF &&
+object 9671cbee7ad26528645b2665c8f74d39a6288864
+type commit
+tag note-14669883eb004f12636307269f537d59eb143125
+tagger C O Mitter <committer@example.com> 1112912113 -0700
+
+spam
+EOF
+	git-cat-file tag 1245491fece5910086bc1870a4a746256f8a7ecf > note.output &&
+	cmp note.expect note.output &&
+	cat > note.expect << EOF &&
+object 9671cbee7ad26528645b2665c8f74d39a6288864
+type commit
+tag note-ad2099b641be660c4e616bf0b46dcaca391764af
+tagger C O Mitter <committer@example.com> 1112912173 -0700
+
+spam spam
+EOF
+	git-cat-file tag 466f861dde008d3905d320225eebef727665a3f0 > note.output &&
+	cmp note.expect note.output &&
+	cat > note.expect << EOF &&
+object 301711b66fe71164f646b798706a2c1f7024da8d
+type commit
+tag note-c1afd1d9a4e2df7efbb29ff88e50e866e88eb108
+tagger C O Mitter <committer@example.com> 1112912233 -0700
+
+spam spam spam
+EOF
+	git-cat-file tag 93bbbc95a42852552494327537263d475aac1789 > note.output &&
+	cmp note.expect note.output
+'
+
+# Verify output from git-note -l
+
+test_expect_success 'Testing git-note -l' '
+	cat > note.expect << EOF &&
+=== Notes on commit 9671cbe (Second commit) by A U Thor <author@example.com> on Thu, 7 Apr 2005 15:14:13 -0700
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:15:13 2005 -0700
+spam
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:16:13 2005 -0700
+spam spam
+
+=== Notes on commit 301711b (Initial commit) by A U Thor <author@example.com> on Thu, 7 Apr 2005 15:13:13 -0700
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:17:13 2005 -0700
+spam spam spam
+EOF
+	git-note -l > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Testing git-note -l <commit>' '
+	cat > note.expect << EOF &&
+=== Notes on commit 9671cbe (Second commit) by A U Thor <author@example.com> on Thu, 7 Apr 2005 15:14:13 -0700
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:15:13 2005 -0700
+spam
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:16:13 2005 -0700
+spam spam
+EOF
+	git-note -l 9671cbee7ad26528645b2665c8f74d39a6288864 > note.output &&
+	cmp note.expect note.output &&
+	cat > note.expect << EOF &&
+=== Notes on commit 301711b (Initial commit) by A U Thor <author@example.com> on Thu, 7 Apr 2005 15:13:13 -0700
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:17:13 2005 -0700
+spam spam spam
+EOF
+	git-note -l 301711b66fe71164f646b798706a2c1f7024da8d > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Testing git-note -l <note> <note> <note>' '
+	cat > note.expect << EOF &&
+
+=== Note 93bbbc95a42852552494327537263d475aac1789
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:17:13 2005 -0700
+spam spam spam
+
+=== Note 466f861dde008d3905d320225eebef727665a3f0
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:16:13 2005 -0700
+spam spam
+
+=== Note 1245491fece5910086bc1870a4a746256f8a7ecf
+
+--- by C O Mitter <committer@example.com> Thu Apr 7 15:15:13 2005 -0700
+spam
+EOF
+	git-note -l 93bbbc95a42852552494327537263d475aac1789 \
+	            466f861dde008d3905d320225eebef727665a3f0 \
+	            1245491fece5910086bc1870a4a746256f8a7ecf > note.output &&
+	cmp note.expect note.output
+'
+
+# Verify that notes show up in git-show-ref and git-for-each-ref
+
+test_expect_success 'Testing git-show-ref with notes' '
+	cat > note.expect << EOF &&
+9671cbee7ad26528645b2665c8f74d39a6288864 refs/heads/master
+93bbbc95a42852552494327537263d475aac1789 refs/notes/301711b66fe71164f646b798706a2c1f7024da8d/93bbbc95a42852552494327537263d475aac1789
+1245491fece5910086bc1870a4a746256f8a7ecf refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/1245491fece5910086bc1870a4a746256f8a7ecf
+466f861dde008d3905d320225eebef727665a3f0 refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/466f861dde008d3905d320225eebef727665a3f0
+EOF
+	git-show-ref > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Testing git-show-ref --notes' '
+	cat > note.expect << EOF &&
+93bbbc95a42852552494327537263d475aac1789 refs/notes/301711b66fe71164f646b798706a2c1f7024da8d/93bbbc95a42852552494327537263d475aac1789
+1245491fece5910086bc1870a4a746256f8a7ecf refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/1245491fece5910086bc1870a4a746256f8a7ecf
+466f861dde008d3905d320225eebef727665a3f0 refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/466f861dde008d3905d320225eebef727665a3f0
+EOF
+	git-show-ref --notes > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Testing git-for-each-ref refs/notes' '
+	cat > note.expect << EOF &&
+93bbbc95a42852552494327537263d475aac1789 tag	refs/notes/301711b66fe71164f646b798706a2c1f7024da8d/93bbbc95a42852552494327537263d475aac1789
+1245491fece5910086bc1870a4a746256f8a7ecf tag	refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/1245491fece5910086bc1870a4a746256f8a7ecf
+466f861dde008d3905d320225eebef727665a3f0 tag	refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/466f861dde008d3905d320225eebef727665a3f0
+EOF
+	git-for-each-ref refs/notes > note.output &&
+	cmp note.expect note.output
+'
+
+# Verify output from git-log/git-show/git-whatchanged --decorate
+
+test_expect_success 'Testing git-log --decorate' '
+	cat > note.expect << EOF &&
+commit 9671cbee7ad26528645b2665c8f74d39a6288864 (refs/heads/master)
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:14:13 2005 -0700
+
+    Second commit
+
+Notes:
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:15:13 2005 -0700
+    spam
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:16:13 2005 -0700
+    spam spam
+
+commit 301711b66fe71164f646b798706a2c1f7024da8d
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:13:13 2005 -0700
+
+    Initial commit
+
+Notes:
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:17:13 2005 -0700
+    spam spam spam
+EOF
+	git-log --decorate > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Testing git-show --decorate' '
+	cat > note.expect << EOF &&
+commit 9671cbee7ad26528645b2665c8f74d39a6288864 (refs/heads/master)
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:14:13 2005 -0700
+
+    Second commit
+
+Notes:
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:15:13 2005 -0700
+    spam
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:16:13 2005 -0700
+    spam spam
+
+diff --git a/foo b/foo
+index 257cc56..3bd1f0e 100644
+--- a/foo
++++ b/foo
+@@ -1 +1,2 @@
+ foo
++bar
+EOF
+	git-show --decorate > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Testing git-whatchanged --decorate' '
+	cat > note.expect << EOF &&
+commit 9671cbee7ad26528645b2665c8f74d39a6288864 (refs/heads/master)
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:14:13 2005 -0700
+
+    Second commit
+
+Notes:
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:15:13 2005 -0700
+    spam
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:16:13 2005 -0700
+    spam spam
+
+:100644 100644 257cc56... 3bd1f0e... M	foo
+
+commit 301711b66fe71164f646b798706a2c1f7024da8d
+Author: A U Thor <author@example.com>
+Date:   Thu Apr 7 15:13:13 2005 -0700
+
+    Initial commit
+
+Notes:
+
+    --- by C O Mitter <committer@example.com> Thu Apr 7 15:17:13 2005 -0700
+    spam spam spam
+
+:000000 100644 0000000... 257cc56... A	foo
+EOF
+	git-whatchanged --decorate > note.output &&
+	cmp note.expect note.output
+'
+
+# Verify successful removal of notes
+
+test_expect_success 'Testing git-note -d <note>' '
+	cat > note.expect << EOF &&
+Deleting note 93bbbc95a42852552494327537263d475aac1789
+EOF
+	git-note -d 93bbbc95a42852552494327537263d475aac1789 > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Verify repo state after git-note -d <note>' '
+	cat > note.expect << EOF &&
+1245491fece5910086bc1870a4a746256f8a7ecf refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/1245491fece5910086bc1870a4a746256f8a7ecf
+466f861dde008d3905d320225eebef727665a3f0 refs/notes/9671cbee7ad26528645b2665c8f74d39a6288864/466f861dde008d3905d320225eebef727665a3f0
+EOF
+	git-show-ref --notes > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Testing git-note -d <commit>' '
+	cat > note.expect << EOF &&
+Deleting note 1245491fece5910086bc1870a4a746256f8a7ecf associated with commit 9671cbee7ad26528645b2665c8f74d39a6288864
+Deleting note 466f861dde008d3905d320225eebef727665a3f0 associated with commit 9671cbee7ad26528645b2665c8f74d39a6288864
+EOF
+	git-note -d 9671cbee7ad26528645b2665c8f74d39a6288864 > note.output &&
+	cmp note.expect note.output
+'
+test_expect_success 'Verify repo state after git-note -d <commit>' '
+	cat > note.expect << EOF &&
+EOF
+	git-show-ref --notes > note.output
+	test "$?" == "1" &&
+	cmp note.expect note.output
+'
+
+# Testing of clone/fetch/push?
+
+test_done
-- 
1.5.2.101.gee49f
Previous: Johan HerlandNext: Johan Herland
Message 24 of 53 in “[RFC] Second parent for reverts”
  1. Daniel BarkalowMay 9, 2007
  2. Johannes SchindelinMay 9, 2007
  3. Shawn O. PearceMay 9, 2007
  4. Johan HerlandMay 9, 2007
  5. Junio C HamanoMay 9, 2007
  6. Linus TorvaldsMay 9, 2007
  7. Linus TorvaldsMay 10, 2007
  8. Johan HerlandMay 10, 2007
  9. Linus TorvaldsMay 10, 2007
  10. 00/15 git-note: A mechanisim for providing free-form after-the-fact annotations on commitsJohan Herland, May 27, 2007
  11. 01/15 git-note: Add git-note command for adding/listing/deleting git notesJohan Herland, May 27, 2007
  12. 02/15 git-note: (Documentation) Add git-note manual pageJohan Herland, May 27, 2007
  13. 03/15 git-note: (Administrivia) Add git-note to Makefile, .gitignore, etc.Johan Herland, May 27, 2007
  14. 04/15 git-note: (Plumbing) Add plumbing-level support for git notesJohan Herland, May 27, 2007
  15. 05/15 git-note: (Plumbing) Add support for git notes to git-rev-parse and git-show-refJohan Herland, May 27, 2007
  16. 06/15 git-note: (Documentation) Explain the new '--notes' option to git-rev-parse and git-show-refJohan Herland, May 27, 2007
  17. 07/15 git-note: (Almost plumbing) Add support for git notes to git-pack-refs and git-fsckJohan Herland, May 27, 2007
  18. 08/15 git-note: (Decorations) Add note decorations to "git-{log,show,whatchanged} --decorate"Johan Herland, May 27, 2007
  19. 09/15 git-note: (Documentation) Explain new behaviour of --decorate in git-{log,show,whatchanged}Johan Herland, May 27, 2007
  20. 10/15 git-note: (Transfer) Teach git-clone how to clone notesJohan Herland, May 27, 2007
  21. 11/15 git-note: (Transfer) Teach git-fetch to auto-follow notesJohan Herland, May 27, 2007
  22. 12/15 git-note: (Transfer) Teach git-push to push notes when --all or --notes is givenJohan Herland, May 27, 2007
  23. 13/15 git-note: (Documentation) Explain the new --notes option to git-pushJohan Herland, May 27, 2007
  24. 14/15 git-note: (Tests) Add tests for git-note and associated functionalityJohan Herland, May 27, 2007
  25. 15/15 git-note: Add display of notes to gitkJohan Herland, May 27, 2007
  26. Junio C HamanoMay 27, 2007
  27. Johan HerlandMay 28, 2007
  28. Jakub NarebskiMay 28, 2007
  29. Linus TorvaldsMay 28, 2007
  30. Johan HerlandMay 28, 2007
  31. Linus TorvaldsMay 28, 2007
  32. Johan HerlandMay 28, 2007
  33. Linus TorvaldsMay 28, 2007
  34. Johan HerlandMay 28, 2007
  35. Junio C HamanoMay 28, 2007
  36. Shawn O. PearceMay 28, 2007
  37. Johannes SchindelinMay 28, 2007
  38. Linus TorvaldsMay 29, 2007
  39. Shawn O. PearceMay 29, 2007
  40. Jakub NarebskiMay 29, 2007
  41. Andy ParkinsMay 29, 2007
  42. Johannes SchindelinMay 29, 2007
  43. Johan HerlandMay 29, 2007
  44. Jeff KingMay 29, 2007
  45. Johan HerlandMay 29, 2007
  46. Junio C HamanoMay 28, 2007
  47. Shawn O. PearceMay 28, 2007
  48. Add fsck_verify_ref_to_tag_object() to verify that refname matches name stored in tag objectJohan Herland, May 28, 2007
  49. Michael S. TsirkinMay 28, 2007
  50. Michael S. TsirkinMay 28, 2007
  51. Johan HerlandMay 28, 2007
  52. Martin LanghoffMay 10, 2007
  53. Junio C HamanoMay 10, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.