diff --git a/pkg/object/id.go b/pkg/object/id.go index e4871a93..26e70f70 100644 --- a/pkg/object/id.go +++ b/pkg/object/id.go @@ -25,6 +25,9 @@ func NewIDFromV2(idV2 *refs.ObjectID) *ID { // NewID creates and initializes blank ID. // // Works similar as NewIDFromV2(new(ObjectID)). +// +// Defaults: +// - value: nil. func NewID() *ID { return NewIDFromV2(new(refs.ObjectID)) } diff --git a/pkg/object/id_test.go b/pkg/object/id_test.go index e5e80db2..e4086d82 100644 --- a/pkg/object/id_test.go +++ b/pkg/object/id_test.go @@ -71,6 +71,11 @@ func TestID_Parse(t *testing.T) { } func TestID_String(t *testing.T) { + t.Run("nil", func(t *testing.T) { + id := NewID() + require.Empty(t, id.String()) + }) + t.Run("should be equal", func(t *testing.T) { for i := 0; i < 10; i++ { t.Run(strconv.Itoa(i), func(t *testing.T) { @@ -124,3 +129,14 @@ func TestID_ToV2(t *testing.T) { require.Nil(t, x.ToV2()) }) } + +func TestNewID(t *testing.T) { + t.Run("default values", func(t *testing.T) { + id := NewID() + + // convert to v2 message + idV2 := id.ToV2() + + require.Nil(t, idV2.GetValue()) + }) +}