Added snapshot package and tests

This commit is contained in:
Priya Wadhwa
2018-02-28 11:05:57 -08:00
parent 72a5f1c916
commit 43bad54292
9 changed files with 425 additions and 1 deletions
+17
View File
@@ -18,10 +18,27 @@ package testutil
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"
)
// SetupFiles creates files at path
func SetupFiles(path string, files map[string]string) error {
for p, c := range files {
path := filepath.Join(path, p)
if err := os.MkdirAll(filepath.Dir(path), 0750); err != nil {
return err
}
if err := ioutil.WriteFile(path, []byte(c), 0644); err != nil {
return err
}
}
return nil
}
func CheckErrorAndDeepEqual(t *testing.T, shouldErr bool, err error, expected, actual interface{}) {
if err := checkErr(shouldErr, err); err != nil {
t.Error(err)