Patchwork [3,of,3,V3] schemas: add tests for registering schemas

login
register
mail settings
Submitter Durham Goode
Date Aug. 14, 2013, 9:02 p.m.
Message ID <90e9f67e30392f85068c.1376514125@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2178/
State Changes Requested
Headers show

Comments

Durham Goode - Aug. 14, 2013, 9:02 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1376513405 25200
#      Wed Aug 14 13:50:05 2013 -0700
# Node ID 90e9f67e30392f85068cbb4eafe0a4d26c6810b9
# Parent  d43e79e852d560c9990aa2ac2de878c73e9b88ad
schemas: add tests for registering schemas

Adds a test for reading and registering schemas.

Patch

diff --git a/tests/test-schemas.t b/tests/test-schemas.t
new file mode 100644
--- /dev/null
+++ b/tests/test-schemas.t
@@ -0,0 +1,39 @@ 
+  $ cat > schemaextension.py <<EOF
+  > import os
+  > from mercurial import commands
+  > 
+  > def listschemas(ui, repo, *args, **kwargs):
+  >     if len(repo.schemas) > 0:
+  >         ui.write("\\n".join(["%s = %s" % (k,v) for
+  >                  k,v in repo.schemas.iteritems()]) + "\\n")
+  > 
+  > def register(ui, repo, *args, **kwargs):
+  >     repo.registerschema(args[0], args[1])
+  > 
+  > cmdtable = {
+  >    "listschemas": (listschemas, [], "hg listschemas"),
+  >    "registerschema": (register, [], "hg registerschema"),
+  > }
+  > 
+  > EOF
+
+  $ abspath=`pwd`/schemaextension.py
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo "foobar = $abspath" >> $HGRCPATH
+
+  $ hg init one
+  $ cd one
+
+# Test registering schemas
+
+  $ echo a > a
+  $ hg add a
+  $ hg commit -ma
+  $ hg listschemas
+  $ hg registerschema foo bar
+  $ hg listschemas
+  foo = bar
+  $ hg registerschema goo car
+  $ hg listschemas
+  goo = car
+  foo = bar