-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathslug_builder_info_test.go
More file actions
55 lines (48 loc) · 1.52 KB
/
slug_builder_info_test.go
File metadata and controls
55 lines (48 loc) · 1.52 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
package storage
import (
"testing"
"github.com/deis/builder/pkg/gitreceive/git"
)
const (
rawSha = "c3b4e4ba8b7267226ff02ad07a3a2cca9c9237de"
s3Endpoint = "http://10.1.2.3:9090"
appName = "myapp"
slugName = "myslug"
)
func TestS3Endpoint(t *testing.T) {
sha, err := git.NewSha(rawSha)
if err != nil {
t.Fatalf("error building git sha (%s)", err)
}
sbi := NewSlugBuilderInfo(s3Endpoint, appName, slugName, sha)
expectedPushURL := s3Endpoint + "/git/" + sbi.PushKey()
if sbi.PushURL() != expectedPushURL {
t.Errorf("push URL %s didn't match expected %s", sbi.PushURL(), expectedPushURL)
}
expectedTarURL := s3Endpoint + "/git/" + 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, 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, appName, slugName, sha)
expectedTarKey := "home/" + slugName + "/tar"
if sbi.TarKey() != expectedTarKey {
t.Errorf("tar key %s didn't match expected %s", sbi.TarKey(), expectedTarKey)
}
}