github.com/YousefHaggyHeroku/pack@v1.5.5/internal/blob/blob_test.go (about) 1 package blob_test 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 8 "github.com/sclevine/spec" 9 "github.com/sclevine/spec/report" 10 11 "github.com/YousefHaggyHeroku/pack/internal/blob" 12 h "github.com/YousefHaggyHeroku/pack/testhelpers" 13 ) 14 15 func TestBlob(t *testing.T) { 16 spec.Run(t, "Buildpack", testBlob, spec.Parallel(), spec.Report(report.Terminal{})) 17 } 18 19 func testBlob(t *testing.T, when spec.G, it spec.S) { 20 when("#Blob", func() { 21 when("#Open", func() { 22 var ( 23 blobDir = filepath.Join("testdata", "blob") 24 blobPath string 25 ) 26 27 when("dir", func() { 28 it.Before(func() { 29 blobPath = blobDir 30 }) 31 it("returns a tar reader", func() { 32 assertBlob(t, blob.NewBlob(blobPath)) 33 }) 34 }) 35 36 when("tgz", func() { 37 it.Before(func() { 38 blobPath = h.CreateTGZ(t, blobDir, ".", -1) 39 }) 40 41 it.After(func() { 42 h.AssertNil(t, os.Remove(blobPath)) 43 }) 44 it("returns a tar reader", func() { 45 assertBlob(t, blob.NewBlob(blobPath)) 46 }) 47 }) 48 49 when("tar", func() { 50 it.Before(func() { 51 blobPath = h.CreateTAR(t, blobDir, ".", -1) 52 }) 53 54 it.After(func() { 55 h.AssertNil(t, os.Remove(blobPath)) 56 }) 57 it("returns a tar reader", func() { 58 assertBlob(t, blob.NewBlob(blobPath)) 59 }) 60 }) 61 }) 62 }) 63 }