forked from getporter/cnab-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_test.go
53 lines (42 loc) · 1.03 KB
/
import_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package packager
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/cnabio/cnab-go/bundle/loader"
)
func TestImport(t *testing.T) {
tempDir, err := ioutil.TempDir("", "duffle-import-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempDir)
is := assert.New(t)
im := Importer{
Source: "testdata/examplebun-0.1.0.tgz",
Destination: tempDir,
Loader: loader.NewLoader(),
}
if err := im.Import(); err != nil {
t.Fatalf("import failed: %v", err)
}
expectedBundlePath := filepath.Join(tempDir, "examplebun-0.1.0")
is.DirExistsf(expectedBundlePath, "expected examplebun to exist")
}
func TestMalformedImport(t *testing.T) {
tempDir, err := ioutil.TempDir("", "duffle-import-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempDir)
im := Importer{
Source: "testdata/malformed-0.1.0.tgz",
Destination: tempDir,
Loader: loader.NewLoader(),
}
if err = im.Import(); err == nil {
t.Error("expected malformed bundle error")
}
}