Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reader_test.go « reader « zip « internal - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0910c7d49f59c7b0c173933d80582421da1a4d20 (plain)
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
package reader

import (
	"io/ioutil"
	"os"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestNewReader(t *testing.T) {
	zipFile, err := os.Open("../../../shared/pages/group/zip.gitlab.io/public.zip")
	require.NoError(t, err)
	zfi, err := zipFile.Stat()
	require.NoError(t, err)

	reader, err := New(zipFile, zfi.Size())
	require.NoError(t, err)

	f, fi, err := reader.Open("index.html")
	require.NoError(t, err)
	defer f.Close()
	require.NotZero(t, fi.Size())

	actualContents, err := ioutil.ReadAll(f)
	require.NoError(t, err, "read zip entry contents")
	require.Equal(t, "zip/index.html\n", string(actualContents), "compare zip entry contents")

	_, _, err = reader.Open("unknown.html")
	require.EqualError(t, err, "\"public/unknown.html\": not found")

}