Skip to content

Commit 96e6dfa

Browse files
author
Aaron Schlesinger
committed
fix(slug_builder_info.go,slug_builder_info_test.go): use proper git sha name for push key
and add tests for it
1 parent 2ed89af commit 96e6dfa

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

pkg/gitreceive/storage/slug_builder_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type SlugBuilderInfo struct {
1818
func NewSlugBuilderInfo(s3Endpoint, appName, slugName string, gitSha *git.SHA) *SlugBuilderInfo {
1919
tarKey := fmt.Sprintf("home/%s/tar", slugName)
2020
// this is where workflow tells slugrunner to download the slug from, so we have to tell slugbuilder to upload it to here
21-
pushKey := fmt.Sprintf("home/%s:git-%s/push", appName, gitSha.Full)
21+
pushKey := fmt.Sprintf("home/%s:git-%s/push", appName, gitSha.Full())
2222

2323
return &SlugBuilderInfo{
2424
pushKey: pushKey,

pkg/gitreceive/storage/slug_builder_info_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,27 @@ func TestS3Endpoint(t *testing.T) {
2929
t.Errorf("tar URL %s didn't match expected %s", sbi.TarURL(), expectedTarURL)
3030
}
3131
}
32+
33+
func TestPushKey(t *testing.T) {
34+
sha, err := git.NewSha(rawSha)
35+
if err != nil {
36+
t.Fatalf("error building git sha (%s)", err)
37+
}
38+
sbi := NewSlugBuilderInfo(s3Endpoint, appName, slugName, sha)
39+
expectedPushKey := "home/" + appName + ":git-" + sha.Full() + "/push"
40+
if sbi.PushKey() != expectedPushKey {
41+
t.Errorf("push key %s didn't match expected %s", sbi.PushKey(), expectedPushKey)
42+
}
43+
}
44+
45+
func TestTarKey(t *testing.T) {
46+
sha, err := git.NewSha(rawSha)
47+
if err != nil {
48+
t.Fatalf("error building git sha (%s)", err)
49+
}
50+
sbi := NewSlugBuilderInfo(s3Endpoint, appName, slugName, sha)
51+
expectedTarKey := "home/" + slugName + "/tar"
52+
if sbi.TarKey() != expectedTarKey {
53+
t.Errorf("tar key %s didn't match expected %s", sbi.TarKey(), expectedTarKey)
54+
}
55+
}

0 commit comments

Comments
 (0)