undocker/internal/tartest/tartest_test.go

29 lines
669 B
Go
Raw Normal View History

package tartest
2021-05-24 00:11:58 +03:00
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTarball(t *testing.T) {
bk := Tarball{File{Name: "entrypoint.sh", Contents: bytes.NewBufferString("hello")}}
img := Tarball{
2021-05-24 00:11:58 +03:00
File{Name: "backup.tar", Contents: bk.Buffer()},
2021-05-24 00:11:58 +03:00
File{Name: "entrypoint.sh", Contents: bytes.NewBufferString("bye")},
Dir{Name: "bin"},
Hardlink{Name: "entrypoint2"},
}
2021-05-24 00:11:58 +03:00
got := Extract(t, img.Buffer())
2021-05-24 00:11:58 +03:00
want := []Extractable{
2021-05-24 00:11:58 +03:00
File{Name: "backup.tar", Contents: bk.Buffer()},
2021-05-24 00:11:58 +03:00
File{Name: "entrypoint.sh", Contents: bytes.NewBufferString("bye")},
Dir{Name: "bin"},
Hardlink{Name: "entrypoint2"},
}
assert.Equal(t, want, got)
}