diff --git a/pachca.go b/pachca.go index e25967f..75f2301 100644 --- a/pachca.go +++ b/pachca.go @@ -1658,6 +1658,11 @@ func (p Properties) Names() []string { return result } +// IsSet returns true if property has a value +func (p *Property) IsSet() bool { + return p != nil && p.Value != "" +} + // IsText returns true if property has text type func (p *Property) IsText() bool { return p != nil && p.Type == PROP_TYPE_TEXT diff --git a/pachca_test.go b/pachca_test.go index 72e2b9c..9614465 100644 --- a/pachca_test.go +++ b/pachca_test.go @@ -326,6 +326,10 @@ func (s *PachcaSuite) TestPropertiesHelpers(c *C) { c.Assert(p.Find("test1"), NotNil) c.Assert(p.Has("test1"), Equals, true) + c.Assert(p.Get(6).IsSet(), Equals, false) + c.Assert(p.Get(10).IsSet(), Equals, false) + c.Assert(p.Get(1).IsSet(), Equals, true) + c.Assert(p.FindAny("abcd", "test100", "test"), IsNil) c.Assert(p.HasAny("abcd", "test100", "test"), Equals, false) c.Assert(p.FindAny("abcd", "test4", "test").Name, Equals, "test4")