Skip to content

Commit

Permalink
container: Improve testing and increase coverage (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Oct 1, 2024
2 parents a0572ad + 1342e38 commit 05f1303
Show file tree
Hide file tree
Showing 3 changed files with 1,001 additions and 295 deletions.
10 changes: 8 additions & 2 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ func (x Container) MarshalJSON() ([]byte, error) {
//
// See also MarshalJSON.
func (x *Container) UnmarshalJSON(data []byte) error {
return x.v2.UnmarshalJSON(data)
var m container.Container
if err := m.UnmarshalJSON(data); err != nil {
return err
}
return x.readFromV2(m, false)
}

// Init initializes all internal data of the Container required by NeoFS API
Expand Down Expand Up @@ -557,6 +561,8 @@ func (x Container) AssertID(id cid.ID) bool {
// Version returns the NeoFS API version this container was created with.
func (x Container) Version() version.Version {
var v version.Version
_ = v.ReadFromV2(*x.v2.GetVersion()) // No, this can't fail for x.
if m := x.v2.GetVersion(); m != nil {
_ = v.ReadFromV2(*m)
}
return v
}
Loading

0 comments on commit 05f1303

Please sign in to comment.