mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/shed: rename StructField.Unmarshal to StructField.Get
This commit is contained in:
parent
895aadc026
commit
1f7dd164bc
2 changed files with 9 additions and 9 deletions
|
|
@ -41,9 +41,9 @@ func (db *DB) NewStructField(name string) (f StructField, err error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// Unmarshal unmarshals data fromt the database to a provided val.
|
||||
// Get unmarshals data from the database to a provided val.
|
||||
// If the data is not found leveldb.ErrNotFound is returned.
|
||||
func (f StructField) Unmarshal(val interface{}) (err error) {
|
||||
func (f StructField) Get(val interface{}) (err error) {
|
||||
b, err := f.db.Get(f.key)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
// TestStructField validates put and unmarshal operations
|
||||
// TestStructField validates put and get operations
|
||||
// of the StructField.
|
||||
func TestStructField(t *testing.T) {
|
||||
db, cleanupFunc := newTestDB(t)
|
||||
|
|
@ -37,9 +37,9 @@ func TestStructField(t *testing.T) {
|
|||
A string
|
||||
}
|
||||
|
||||
t.Run("unmarshal empty", func(t *testing.T) {
|
||||
t.Run("get empty", func(t *testing.T) {
|
||||
var s complexStructure
|
||||
err := complexField.Unmarshal(&s)
|
||||
err := complexField.Get(&s)
|
||||
if err != leveldb.ErrNotFound {
|
||||
t.Fatalf("got error %v, want %v", err, leveldb.ErrNotFound)
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ func TestStructField(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
var got complexStructure
|
||||
err = complexField.Unmarshal(&got)
|
||||
err = complexField.Get(&got)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ func TestStructField(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
var got complexStructure
|
||||
err = complexField.Unmarshal(&got)
|
||||
err = complexField.Get(&got)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ func TestStructField(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
var got complexStructure
|
||||
err := complexField.Unmarshal(&got)
|
||||
err := complexField.Get(&got)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ func TestStructField(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
var got complexStructure
|
||||
err := complexField.Unmarshal(&got)
|
||||
err := complexField.Get(&got)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue