This is a first attempt at doing some fixes on the unit tests. I have been having problems getting the full test suite to run on my machines, so I am trying to get this remedied. I am hoping to do it as a series of small patches, rather than one very large patch, so this is the first of those. Since I can't run 'rake test:units' right now, I can't really tell if this breaks the whole test suite or not, so I am looking for feedback from someone who _is_ able to run that. I have added some tests to pool_test.rb and been able to run them successfully with 'ruby test/unit/pool_test.rb', so I know this component is fine, just not what effect it might have on everything else. Signed-off-by: Jason Guiditta <jguiditt at redhat.com> --- src/test/fixtures/pools.yml | 96 ++++++++++++++++++------------------------ src/test/unit/pool_test.rb | 8 +++- 2 files changed, 47 insertions(+), 57 deletions(-) diff --git a/src/test/fixtures/pools.yml b/src/test/fixtures/pools.yml index 181a75b..41241f6 100644 --- a/src/test/fixtures/pools.yml +++ b/src/test/fixtures/pools.yml @@ -1,100 +1,86 @@ -one: - id: 1 +root_dir_pool: + name: 'root' + type: 'DirectoryPool' + lft: 1 + rgt: 28 + +hw_dir_pool: + name: 'hardware' + type: 'DirectoryPool' + parent_id: <%= Fixtures.identify(:root_dir_pool) %> + lft: 2 + rgt: 25 + +smart_dir_pool: + name: 'users' + type: 'DirectoryPool' + parent_id: <%= Fixtures.identify(:root_dir_pool) %> + lft: 26 + rgt: 27 + +default: name: 'default' type: 'HardwarePool' - parent_id: 12 - created_at: '2008-02-13 15:42:43.417883' - updated_at: '2008-02-14 16:41:42.417883' + parent_id: <%= Fixtures.identify(:hw_dir_pool) %> lft: 3 rgt: 24 -two: - id: 2 +foobar_hosts: name: 'foobar hosts' type: 'VmResourcePool' - parent_id: 1 + parent_id: <%= Fixtures.identify(:default) %> lft: 4 rgt: 5 -three: - id: 3 +corp_com: name: 'corp.com' type: 'HardwarePool' - parent_id: 1 + parent_id: <%= Fixtures.identify(:default) %> lft: 6 rgt: 23 -four: - id: 4 +corp_com_dev: name: 'corp.com dev' type: 'HardwarePool' - parent_id: 3 + parent_id: <%= Fixtures.identify(:corp_com) %> lft: 7 rgt: 8 -five: - id: 5 +corp_com_qa: name: 'corp.com qa' type: 'HardwarePool' - parent_id: 3 + parent_id: <%= Fixtures.identify(:corp_com) %> lft: 9 rgt: 20 -six: - id: 6 +corp_com_production_vms: name: 'corp.com production vms' type: 'VmResourcePool' - parent_id: 3 + parent_id: <%= Fixtures.identify(:corp_com) %> lft: 21 rgt: 22 -seven: - id: 7 +foobar: name: 'foobar' type: 'VmResourcePool' - parent_id: 5 + parent_id: <%= Fixtures.identify(:corp_com_qa) %> lft: 10 rgt: 11 -eight: - id: 8 +some_foobar_hardware: name: 'some foobar hardware' type: 'HardwarePool' - parent_id: 5 + parent_id: <%= Fixtures.identify(:corp_com_qa) %> lft: 12 rgt: 15 -nine: - id: 9 +some_more_foobar_hardware: name: 'some more foobar hardware' type: 'HardwarePool' - parent_id: 8 + parent_id: <%= Fixtures.identify(:some_foobar_hardware) %> lft: 13 rgt: 14 -ten: - id: 10 +yet_another_pool: name: 'yet another pool' type: 'VmResourcePool' - parent_id: 5 + parent_id: <%= Fixtures.identify(:corp_com_qa) %> lft: 16 rgt: 17 prodops_pool: - id: 11 name: 'Production Operations' type: 'HardwarePool' - parent_id: 5 + parent_id: <%= Fixtures.identify(:corp_com_qa) %> lft: 18 rgt: 19 -hw_dir_pool: - id: 12 - name: 'hardware' - type: 'DirectoryPool' - parent_id: 13 - lft: 2 - rgt: 25 -root_dir_pool: - id: 13 - name: 'root' - type: 'DirectoryPool' - lft: 1 - rgt: 28 -smart_dir_pool: - id: 14 - name: 'hardware' - type: 'DirectoryPool' - parent_id: 13 - lft: 26 - rgt: 27 - diff --git a/src/test/unit/pool_test.rb b/src/test/unit/pool_test.rb index c591e58..c0ca7cc 100644 --- a/src/test/unit/pool_test.rb +++ b/src/test/unit/pool_test.rb @@ -23,7 +23,11 @@ class PoolTest < Test::Unit::TestCase fixtures :pools # Replace this with your real tests. - def test_truth - assert true + def test_get_name + assert_equal(pools(:prodops_pool).name, 'Production Operations') + end + + def test_get_parent + assert_equal(pools(:prodops_pool).parent.name, 'corp.com qa') end end -- 1.5.6.5
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jason Giuditta wrote:> This is a first attempt at doing some fixes on the unit tests. I have > been having problems getting the full test suite to run on my machines, > so I am trying to get this remedied. I am hoping to do it as a series of > small patches, rather than one very large patch, so this is the first of > those. Since I can't run 'rake test:units' right now, I can't really > tell if this breaks the whole test suite or not, so I am looking for > feedback from someone who _is_ able to run that. I have added some tests > to pool_test.rb and been able to run them successfully with 'ruby > test/unit/pool_test.rb', so I know this component is fine, just not what > effect it might have on everything else.Looks good so far.> > Signed-off-by: Jason Guiditta <jguiditt at redhat.com> > --- > src/test/fixtures/pools.yml | 96 ++++++++++++++++++------------------------ > src/test/unit/pool_test.rb | 8 +++- > 2 files changed, 47 insertions(+), 57 deletions(-) > > diff --git a/src/test/fixtures/pools.yml b/src/test/fixtures/pools.yml > index 181a75b..41241f6 100644 > --- a/src/test/fixtures/pools.yml > +++ b/src/test/fixtures/pools.yml > @@ -1,100 +1,86 @@ > -one: > - id: 1 > +root_dir_pool:I like the using of meaningful names for the fixtures. It makes usage in tests much clearler.> + name: 'root' > + type: 'DirectoryPool'You don't need to wrap strings in single quotes. Everything after the colon is trimmed and treated as a string.> + lft: 1 > + rgt: 28 > + > +hw_dir_pool: > + name: 'hardware' > + type: 'DirectoryPool' > + parent_id: <%= Fixtures.identify(:root_dir_pool) %> > + lft: 2 > + rgt: 25 > + > +smart_dir_pool: > + name: 'users' > + type: 'DirectoryPool' > + parent_id: <%= Fixtures.identify(:root_dir_pool) %> > + lft: 26 > + rgt: 27 > + > +default: > name: 'default' > type: 'HardwarePool' > - parent_id: 12 > - created_at: '2008-02-13 15:42:43.417883' > - updated_at: '2008-02-14 16:41:42.417883' > + parent_id: <%= Fixtures.identify(:hw_dir_pool) %> > lft: 3 > rgt: 24 > -two: > - id: 2 > +foobar_hosts: > name: 'foobar hosts' > type: 'VmResourcePool' > - parent_id: 1 > + parent_id: <%= Fixtures.identify(:default) %> > lft: 4 > rgt: 5 > -three: > - id: 3 > +corp_com: > name: 'corp.com' > type: 'HardwarePool' > - parent_id: 1 > + parent_id: <%= Fixtures.identify(:default) %> > lft: 6 > rgt: 23 > -four: > - id: 4 > +corp_com_dev: > name: 'corp.com dev' > type: 'HardwarePool' > - parent_id: 3 > + parent_id: <%= Fixtures.identify(:corp_com) %> > lft: 7 > rgt: 8 > -five: > - id: 5 > +corp_com_qa: > name: 'corp.com qa' > type: 'HardwarePool' > - parent_id: 3 > + parent_id: <%= Fixtures.identify(:corp_com) %> > lft: 9 > rgt: 20 > -six: > - id: 6 > +corp_com_production_vms: > name: 'corp.com production vms' > type: 'VmResourcePool' > - parent_id: 3 > + parent_id: <%= Fixtures.identify(:corp_com) %> > lft: 21 > rgt: 22 > -seven: > - id: 7 > +foobar: > name: 'foobar' > type: 'VmResourcePool' > - parent_id: 5 > + parent_id: <%= Fixtures.identify(:corp_com_qa) %> > lft: 10 > rgt: 11 > -eight: > - id: 8 > +some_foobar_hardware: > name: 'some foobar hardware' > type: 'HardwarePool' > - parent_id: 5 > + parent_id: <%= Fixtures.identify(:corp_com_qa) %> > lft: 12 > rgt: 15 > -nine: > - id: 9 > +some_more_foobar_hardware: > name: 'some more foobar hardware' > type: 'HardwarePool' > - parent_id: 8 > + parent_id: <%= Fixtures.identify(:some_foobar_hardware) %> > lft: 13 > rgt: 14 > -ten: > - id: 10 > +yet_another_pool: > name: 'yet another pool' > type: 'VmResourcePool' > - parent_id: 5 > + parent_id: <%= Fixtures.identify(:corp_com_qa) %> > lft: 16 > rgt: 17 > prodops_pool: > - id: 11 > name: 'Production Operations' > type: 'HardwarePool' > - parent_id: 5 > + parent_id: <%= Fixtures.identify(:corp_com_qa) %> > lft: 18 > rgt: 19 > -hw_dir_pool: > - id: 12 > - name: 'hardware' > - type: 'DirectoryPool' > - parent_id: 13 > - lft: 2 > - rgt: 25 > -root_dir_pool: > - id: 13 > - name: 'root' > - type: 'DirectoryPool' > - lft: 1 > - rgt: 28 > -smart_dir_pool: > - id: 14 > - name: 'hardware' > - type: 'DirectoryPool' > - parent_id: 13 > - lft: 26 > - rgt: 27 > - > diff --git a/src/test/unit/pool_test.rb b/src/test/unit/pool_test.rb > index c591e58..c0ca7cc 100644 > --- a/src/test/unit/pool_test.rb > +++ b/src/test/unit/pool_test.rb > @@ -23,7 +23,11 @@ class PoolTest < Test::Unit::TestCase > fixtures :pools > > # Replace this with your real tests. > - def test_truth > - assert true > + def test_get_name > + assert_equal(pools(:prodops_pool).name, 'Production Operations') > + end > + > + def test_get_parent > + assert_equal(pools(:prodops_pool).parent.name, 'corp.com qa') > end > end- -- Darryl L. Pierce <dpierce at redhat.com> : GPG KEYID: 6C4E7F1B -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAkkTYqsACgkQjaT4DmxOfxudpQCfa9nK4RZytCCh8wc8CdXWqOjH WD0AmwWi5v5GXcZf8F4LS3xN4oW74HE3 =fqAv -----END PGP SIGNATURE----- -------------- next part -------------- A non-text attachment was scrubbed... Name: dpierce.vcf Type: text/x-vcard Size: 319 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20081106/19752adc/attachment.vcf>