Skip to content

Commit

Permalink
Update slug_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Aug 18, 2023
1 parent 33ba34b commit 2d6d199
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ func TestPack_absoluteSrcRelativeSymlinks(t *testing.T) {
// traversing the source directory
t.Fatalf("err: %v", err)
}

// Cannot pack without dereferencing
_, err = Pack(path, slug, false)
if !strings.HasPrefix(err.Error(), "illegal slug error:") {
t.Fatalf("expected illegal slug error, got %q", err)
}
}

func TestPackWithoutIgnoring(t *testing.T) {
Expand Down Expand Up @@ -1088,7 +1094,8 @@ func assertArchiveFixture(t *testing.T, slug *bytes.Buffer, got *Meta) {

tarR := tar.NewReader(gzipR)
var (
symFound bool
sym1Found bool
sym2Found bool
externalTargetFound bool
fileList []string
slugSize int64
Expand All @@ -1115,7 +1122,17 @@ func assertArchiveFixture(t *testing.T, slug *bytes.Buffer, got *Meta) {
if hdr.Linkname != "../bar.txt" {
t.Fatalf("expect target of '../bar.txt', got %q", hdr.Linkname)
}
symFound = true
sym1Found = true
}

if hdr.Name == "sub2/bar.txt" {
if hdr.Typeflag != tar.TypeSymlink {
t.Fatalf("expect symlink for file 'sub2/bar.txt'")
}
if hdr.Linkname != "../sub/bar.txt" {
t.Fatalf("expect target of '../sub/bar.txt', got %q", hdr.Linkname)
}
sym2Found = true
}

if hdr.Name == "example.tf" {
Expand All @@ -1127,8 +1144,8 @@ func assertArchiveFixture(t *testing.T, slug *bytes.Buffer, got *Meta) {
}

// Make sure we saw and handled a symlink
if !symFound {
t.Fatal("expected to find symlink")
if !sym1Found || !sym2Found {
t.Fatal("expected to find two symlinks")
}

// Make sure we saw and handled a dereferenced symlink
Expand Down

0 comments on commit 2d6d199

Please sign in to comment.