mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
replace json.Unmarshal with NewFromJSON in Create
Signed-off-by: Jim Lin <b04705003@ntu.edu.tw>
This commit is contained in:
parent
6c0a036dce
commit
c9ec21e17a
2 changed files with 10 additions and 3 deletions
|
@ -1,7 +1,6 @@
|
||||||
package image // import "github.com/docker/docker/image"
|
package image // import "github.com/docker/docker/image"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -118,8 +117,8 @@ func (is *store) restore() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (is *store) Create(config []byte) (ID, error) {
|
func (is *store) Create(config []byte) (ID, error) {
|
||||||
var img Image
|
var img *Image
|
||||||
err := json.Unmarshal(config, &img)
|
img, err := NewFromJSON(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,14 @@ import (
|
||||||
"gotest.tools/v3/assert/cmp"
|
"gotest.tools/v3/assert/cmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestCreate(t *testing.T) {
|
||||||
|
is, cleanup := defaultImageStore(t)
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
_, err := is.Create([]byte(`{}`))
|
||||||
|
assert.Check(t, cmp.Error(err, "invalid image JSON, no RootFS key"))
|
||||||
|
}
|
||||||
|
|
||||||
func TestRestore(t *testing.T) {
|
func TestRestore(t *testing.T) {
|
||||||
fs, cleanup := defaultFSStoreBackend(t)
|
fs, cleanup := defaultFSStoreBackend(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
Loading…
Reference in a new issue