forked from MediaMath/grim
/
github_archive_test.go
46 lines (36 loc) · 1.02 KB
/
github_archive_test.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package grim
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
// Copyright 2015 MediaMath <http://www.mediamath.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
func TestUnarchiveRepo(t *testing.T) {
temp, err := ioutil.TempDir("", "unarchive-repo-test")
clonePath := "go/src/github.com/baz/foo.bar"
cloned := filepath.Join(temp, clonePath)
wd, _ := os.Getwd()
file := fmt.Sprintf("%s/test_data/TestUnarchiveRepo/baz-foo.bar-v4.0.3-44-fasdfadsflkjlkjlkjlkjlkjlkjlj.tar.gz", wd)
unpacked, err := unarchiveRepo(file, temp, clonePath, testBuildtimeout)
if err != nil {
t.Errorf("|%v|", err)
}
if unpacked != cloned {
t.Errorf("Should have been %s was %s", cloned, unpacked)
}
files, err := ioutil.ReadDir(cloned)
if err != nil {
t.Errorf("|%v|", err)
}
if len(files) != 2 {
t.Errorf("Directory %s had %v files.", cloned, len(files))
}
if !t.Failed() {
//only remove output on success
os.RemoveAll(temp)
}
}