Bug origin

Posted on 2008-09-18 22:43:02 EEST.

Do not read Your code twice to make it much more stable and better. Write unit tests instead.

I ran Midgard test today and started to wonder what's wrong with the code:

midgard-core:ERROR:   midgard_test_metadata.c:490):midgard_test_metadata_check_person_references: 
assertion failed (metadata_property == guid): 
("1dd85b60c20d89485b611dda4935fce5036a2e8a2e8" == "f6b665f1984503790ed91f39b11b5392")

Point is that in this test I checked if person's guid is the same as the one set for object's metadata creator and revisor properties. It's not, obviously.

So what is wrong with code then:

Today I made this commit to propagate metadata properties when object is deleted. What I did wrong? I had set revisor's guid using object's guid (the one which has been deleted), not person's guid. Is it obvious when you read code? This commit fixed this nasty bug, and I needed one hour and a half to find it and fix.

For how long such bug could be existing in Midgard without unit tests? For a month? For a year? I do not want to think about this :)

Thank you GLib testing framework!

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS