| Index: go/src/infra/tools/cipd/local/builder_test.go
|
| diff --git a/go/src/infra/tools/cipd/builder_test.go b/go/src/infra/tools/cipd/local/builder_test.go
|
| similarity index 73%
|
| rename from go/src/infra/tools/cipd/builder_test.go
|
| rename to go/src/infra/tools/cipd/local/builder_test.go
|
| index e4c6acfbda4371bda71afe5b6c2d3ec44e53bff0..510fc1272c68cb4858db236b100d047f1811f44c 100644
|
| --- a/go/src/infra/tools/cipd/builder_test.go
|
| +++ b/go/src/infra/tools/cipd/local/builder_test.go
|
| @@ -2,15 +2,13 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -package cipd
|
| +package local
|
|
|
| import (
|
| "archive/zip"
|
| "bytes"
|
| "crypto/sha1"
|
| "encoding/hex"
|
| - "fmt"
|
| - "io"
|
| "io/ioutil"
|
| "os"
|
| "runtime"
|
| @@ -63,10 +61,10 @@ func TestBuildInstance(t *testing.T) {
|
| out := bytes.Buffer{}
|
| err := BuildInstance(BuildInstanceOptions{
|
| Input: []File{
|
| - makeTestFile("testing/qwerty", "12345", false),
|
| - makeTestFile("abc", "duh", true),
|
| - makeTestSymlink("rel_symlink", "abc"),
|
| - makeTestSymlink("abs_symlink", "/abc/def"),
|
| + NewTestFile("testing/qwerty", "12345", false),
|
| + NewTestFile("abc", "duh", true),
|
| + NewTestSymlink("rel_symlink", "abc"),
|
| + NewTestSymlink("abs_symlink", "/abc/def"),
|
| },
|
| Output: &out,
|
| PackageName: "testing",
|
| @@ -113,8 +111,8 @@ func TestBuildInstance(t *testing.T) {
|
| Convey("Duplicate files fail", t, func() {
|
| err := BuildInstance(BuildInstanceOptions{
|
| Input: []File{
|
| - makeTestFile("a", "12345", false),
|
| - makeTestFile("a", "12345", false),
|
| + NewTestFile("a", "12345", false),
|
| + NewTestFile("a", "12345", false),
|
| },
|
| Output: &bytes.Buffer{},
|
| PackageName: "testing",
|
| @@ -125,7 +123,7 @@ func TestBuildInstance(t *testing.T) {
|
| Convey("Writing to service dir fails", t, func() {
|
| err := BuildInstance(BuildInstanceOptions{
|
| Input: []File{
|
| - makeTestFile(".cipdpkg/stuff", "12345", false),
|
| + NewTestFile(".cipdpkg/stuff", "12345", false),
|
| },
|
| Output: &bytes.Buffer{},
|
| PackageName: "testing",
|
| @@ -186,47 +184,3 @@ func readZip(data []byte) []zippedFile {
|
| }
|
| return files
|
| }
|
| -
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -
|
| -type testFile struct {
|
| - name string
|
| - data string
|
| - executable bool
|
| - symlinkTarget string
|
| -}
|
| -
|
| -func (f *testFile) Name() string { return f.name }
|
| -func (f *testFile) Size() uint64 { return uint64(len(f.data)) }
|
| -func (f *testFile) Executable() bool { return f.executable }
|
| -func (f *testFile) Symlink() bool { return f.symlinkTarget != "" }
|
| -
|
| -func (f *testFile) SymlinkTarget() (string, error) {
|
| - if f.symlinkTarget == "" {
|
| - return "", fmt.Errorf("Not a symlink: %s", f.Name())
|
| - }
|
| - return f.symlinkTarget, nil
|
| -}
|
| -
|
| -func (f *testFile) Open() (io.ReadCloser, error) {
|
| - if f.Symlink() {
|
| - return nil, fmt.Errorf("Can't open symlink: %s", f.Name())
|
| - }
|
| - r := bytes.NewReader([]byte(f.data))
|
| - return ioutil.NopCloser(r), nil
|
| -}
|
| -
|
| -func makeTestFile(name string, data string, executable bool) File {
|
| - return &testFile{
|
| - name: name,
|
| - data: data,
|
| - executable: executable,
|
| - }
|
| -}
|
| -
|
| -func makeTestSymlink(name string, target string) File {
|
| - return &testFile{
|
| - name: name,
|
| - symlinkTarget: target,
|
| - }
|
| -}
|
|
|