test: jsonnetfile marshalling

This commit is contained in:
sh0rez 2019-10-29 22:09:03 +01:00
parent 1caefa556e
commit 6e283c5310
No known key found for this signature in database
GPG key ID: 87C71DF9F8181FF1
4 changed files with 137 additions and 15 deletions

View file

@ -18,7 +18,6 @@ import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"github.com/pkg/errors"
@ -32,9 +31,9 @@ const (
var ErrNoFile = errors.New("no jsonnetfile")
// Load reads a jsonnetfile.(lock).json from disk
func Load(filepath string) (spec.JsonnetFile, error) {
m := spec.JsonnetFile{}
m := spec.New()
bytes, err := ioutil.ReadFile(filepath)
if err != nil {
@ -51,6 +50,7 @@ func Load(filepath string) (spec.JsonnetFile, error) {
return m, nil
}
// Exists returns whether the file at the given path exists
func Exists(path string) (bool, error) {
_, err := os.Stat(path)
if os.IsNotExist(err) {