Skip to content

Commit

Permalink
fix(metadata): fix cbor-gen (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward authored Sep 24, 2020
1 parent 09368ac commit 7011d1e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 0 additions & 2 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
xerrors "golang.org/x/xerrors"
)

//go:generate cbor-gen-for --map-encoding Item

// Item is a single link traversed in a repsonse
type Item struct {
Link cid.Cid
Expand Down
22 changes: 10 additions & 12 deletions metadata/metadata_cbor_gen.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.

package metadata

import (
Expand All @@ -24,14 +22,14 @@ func (t *Item) MarshalCBOR(w io.Writer) error {
scratch := make([]byte, 9)

// t.Link (cid.Cid) (struct)
if len("Link") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Link\" was too long")
if len("link") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"link\" was too long")
}

if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Link"))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("link"))); err != nil {
return err
}
if _, err := io.WriteString(w, "Link"); err != nil {
if _, err := io.WriteString(w, "link"); err != nil {
return err
}

Expand All @@ -40,14 +38,14 @@ func (t *Item) MarshalCBOR(w io.Writer) error {
}

// t.BlockPresent (bool) (bool)
if len("BlockPresent") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"BlockPresent\" was too long")
if len("blockPresent") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"blockPresent\" was too long")
}

if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("BlockPresent"))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("blockPresent"))); err != nil {
return err
}
if _, err := io.WriteString(w, "BlockPresent"); err != nil {
if _, err := io.WriteString(w, "blockPresent"); err != nil {
return err
}

Expand Down Expand Up @@ -91,7 +89,7 @@ func (t *Item) UnmarshalCBOR(r io.Reader) error {

switch name {
// t.Link (cid.Cid) (struct)
case "Link":
case "link":

{

Expand All @@ -104,7 +102,7 @@ func (t *Item) UnmarshalCBOR(r io.Reader) error {

}
// t.BlockPresent (bool) (bool)
case "BlockPresent":
case "blockPresent":

maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions metadata/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func TestDecodeEncodeMetadata(t *testing.T) {
blockPresent := rand.Int31()%2 == 0
initialMetadata = append(initialMetadata, Item{k, blockPresent})
fla.AssembleValue().CreateMap(2, func(fma fluent.MapAssembler) {
fma.AssembleEntry("Link").AssignLink(cidlink.Link{Cid: k})
fma.AssembleEntry("BlockPresent").AssignBool(blockPresent)
fma.AssembleEntry("link").AssignLink(cidlink.Link{Cid: k})
fma.AssembleEntry("blockPresent").AssignBool(blockPresent)
})
}
})
Expand Down

0 comments on commit 7011d1e

Please sign in to comment.