-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathslug_builder_info_test.go
More file actions
68 lines (59 loc) · 2.11 KB
/
slug_builder_info_test.go
File metadata and controls
68 lines (59 loc) · 2.11 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gitreceive
import (
"testing"
"github.com/arschles/assert"
"github.com/deis/builder/pkg/gitreceive/git"
"github.com/deis/builder/pkg/storage"
)
var (
s3Endpoint = &storage.Endpoint{URLStr: "10.1.2.3:9090", Secure: false}
)
func TestS3Endpoint(t *testing.T) {
sha, err := git.NewSha(rawSha)
if err != nil {
t.Fatalf("error building git sha (%s)", err)
}
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
expectedPushURL := s3Endpoint.FullURL() + "/" + bucket + "/" + sbi.PushKey()
if sbi.PushURL() != expectedPushURL {
t.Errorf("push URL %s didn't match expected %s", sbi.PushURL(), expectedPushURL)
}
expectedTarURL := s3Endpoint.FullURL() + "/" + bucket + "/" + sbi.TarKey()
if sbi.TarURL() != expectedTarURL {
t.Errorf("tar URL %s didn't match expected %s", sbi.TarURL(), expectedTarURL)
}
}
func TestPushKey(t *testing.T) {
sha, err := git.NewSha(rawSha)
if err != nil {
t.Fatalf("error building git sha (%s)", err)
}
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
expectedPushKey := "home/" + appName + ":git-" + sha.Short() + "/push"
if sbi.PushKey() != expectedPushKey {
t.Errorf("push key %s didn't match expected %s", sbi.PushKey(), expectedPushKey)
}
}
func TestTarKey(t *testing.T) {
sha, err := git.NewSha(rawSha)
if err != nil {
t.Fatalf("error building git sha (%s)", err)
}
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
expectedTarKey := "home/" + slugName + "/tar"
if sbi.TarKey() != expectedTarKey {
t.Errorf("tar key %s didn't match expected %s", sbi.TarKey(), expectedTarKey)
}
}
func TestAbsoluteSlugObjectKey(t *testing.T) {
sha, err := git.NewSha(rawSha)
assert.NoErr(t, err)
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
assert.Equal(t, sbi.AbsoluteSlugObjectKey(), sbi.PushKey()+"/"+slugTGZName, "absolute slug key")
}
func TestAbsoluteSlugURL(t *testing.T) {
sha, err := git.NewSha(rawSha)
assert.NoErr(t, err)
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
assert.Equal(t, sbi.AbsoluteSlugURL(), sbi.PushURL()+"/"+slugTGZName, "absolute slug URL")
}