From 9f0bc50e539f4b00bba2eeeb5037f41e11a69e3d Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 16 Nov 2020 11:21:28 +0300 Subject: [PATCH] [#197] sdk: Rename getters of Checksum type Signed-off-by: Leonard Lyubich --- pkg/checksum.go | 10 +++++----- pkg/checksum_test.go | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/checksum.go b/pkg/checksum.go index 4182b712..72087a71 100644 --- a/pkg/checksum.go +++ b/pkg/checksum.go @@ -37,8 +37,8 @@ func NewChecksum() *Checksum { return NewChecksumFromV2(new(refs.Checksum)) } -// GetType returns checksum type. -func (c *Checksum) GetType() ChecksumType { +// Type returns checksum type. +func (c *Checksum) Type() ChecksumType { switch (*refs.Checksum)(c).GetType() { case refs.SHA256: return ChecksumSHA256 @@ -49,8 +49,8 @@ func (c *Checksum) GetType() ChecksumType { } } -// GetSum returns checksum bytes. -func (c *Checksum) GetSum() []byte { +// Sum returns checksum bytes. +func (c *Checksum) Sum() []byte { return (*refs.Checksum)(c).GetSum() } @@ -75,7 +75,7 @@ func (c *Checksum) ToV2() *refs.Checksum { } func EqualChecksums(cs1, cs2 *Checksum) bool { - return cs1.GetType() == cs2.GetType() && bytes.Equal(cs1.GetSum(), cs2.GetSum()) + return cs1.Type() == cs2.Type() && bytes.Equal(cs1.Sum(), cs2.Sum()) } // Marshal marshals Checksum into a protobuf binary form. diff --git a/pkg/checksum_test.go b/pkg/checksum_test.go index 9d402a47..41cc9d34 100644 --- a/pkg/checksum_test.go +++ b/pkg/checksum_test.go @@ -25,8 +25,8 @@ func TestChecksum(t *testing.T) { c.SetSHA256(cSHA256) - require.Equal(t, ChecksumSHA256, c.GetType()) - require.Equal(t, cSHA256[:], c.GetSum()) + require.Equal(t, ChecksumSHA256, c.Type()) + require.Equal(t, cSHA256[:], c.Sum()) cV2 := c.ToV2() @@ -38,8 +38,8 @@ func TestChecksum(t *testing.T) { c.SetTillichZemor(cTZ) - require.Equal(t, ChecksumTZ, c.GetType()) - require.Equal(t, cTZ[:], c.GetSum()) + require.Equal(t, ChecksumTZ, c.Type()) + require.Equal(t, cTZ[:], c.Sum()) cV2 = c.ToV2()