Skip to content

Commit

Permalink
fix: use authorized GitHub client to download release tarball
Browse files Browse the repository at this point in the history
Co-authored-by: Jhonathan Aristizabal <jhonathana@vmware.com>
Co-authored-by: Nick Rohn <nrohn@vmware.com>
  • Loading branch information
3 people committed Sep 13, 2022
1 parent 5cec70e commit d3f4ddb
Show file tree
Hide file tree
Showing 7 changed files with 337 additions and 276 deletions.
12 changes: 7 additions & 5 deletions internal/acceptance/workflows/updating_stemcell.feature
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
Feature: As a dependabot, I want to update a stemcell

# This test is brittle. When a new stemcell is released, this will fail.
# We need to fix the stemcell logic to respect the stemcell version constraint.
# Until we do, we need to update the expectations in this file.

Scenario: Find the new stemcell
Given I have a "hello-tile" repository checked out at v0.1.5
And TanzuNetwork has product "stemcells-ubuntu-xenial" with version "621.261"
And I set the Kilnfile stemcell version constraint to "<=621.261"
And TanzuNetwork has product "stemcells-ubuntu-xenial" with version "621.280"
When I invoke kiln
| find-stemcell-version |
| --variable=github_token="${GITHUB_TOKEN}" |
Then stdout contains substring: "621.265"
Then stdout contains substring: "621.280"

Scenario: Update the stemcell
Given I have a "hello-tile" repository checked out at v0.1.5
And TanzuNetwork has product "stemcells-ubuntu-xenial" with version "621.261"
And I set the Kilnfile stemcell version constraint to "<=621.261"
And TanzuNetwork has product "stemcells-ubuntu-xenial" with version "621.280"
And the Kilnfile.lock specifies version "621.0" for the stemcell
When I invoke kiln
| update-stemcell |
Expand Down
40 changes: 40 additions & 0 deletions internal/component/bump_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package component

import (
"github.com/google/go-github/v40/github"
Ω "github.com/onsi/gomega"
"testing"
)

func TestInternal_deduplicateReleasesWithTheSameTagName(t *testing.T) {
please := Ω.NewWithT(t)
b := Bump{
Releases: []*github.RepositoryRelease{
{TagName: ptr("Y")},
{TagName: ptr("1")},
{TagName: ptr("2")},
{TagName: ptr("3")},
{TagName: ptr("3")},
{TagName: ptr("3")},
{TagName: ptr("X")},
{TagName: ptr("2")},
{TagName: ptr("4")},
{TagName: ptr("4")},
},
}
b.deduplicateReleasesWithTheSameTagName()
tags := make([]string, 0, len(b.Releases))
for _, r := range b.Releases {
tags = append(tags, r.GetTagName())
}
please.Expect(tags).To(Ω.Equal([]string{
"Y",
"1",
"2",
"3",
"X",
"4",
}))
}

func ptr[T any](v T) *T { return &v }
33 changes: 1 addition & 32 deletions internal/component/bump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/pivotal-cf/kiln/pkg/cargo"
)

func TestInternal_calculateComponentBumps(t *testing.T) {
func TestCalculateBumps(t *testing.T) {
t.Parallel()
please := Ω.NewWithT(t)

Expand Down Expand Up @@ -86,37 +86,6 @@ func TestInternal_calculateComponentBumps(t *testing.T) {
})
}

func TestInternal_deduplicateReleasesWithTheSameTagName(t *testing.T) {
please := Ω.NewWithT(t)
b := Bump{
Releases: []*github.RepositoryRelease{
{TagName: strPtr("Y")},
{TagName: strPtr("1")},
{TagName: strPtr("2")},
{TagName: strPtr("3")},
{TagName: strPtr("3")},
{TagName: strPtr("3")},
{TagName: strPtr("X")},
{TagName: strPtr("2")},
{TagName: strPtr("4")},
{TagName: strPtr("4")},
},
}
b.deduplicateReleasesWithTheSameTagName()
tags := make([]string, 0, len(b.Releases))
for _, r := range b.Releases {
tags = append(tags, r.GetTagName())
}
please.Expect(tags).To(Ω.Equal([]string{
"Y",
"1",
"2",
"3",
"X",
"4",
}))
}

func TestInternal_addReleaseNotes(t *testing.T) {
please := Ω.NewWithT(t)

Expand Down
203 changes: 0 additions & 203 deletions internal/component/fakes_internal/github_new_request_doer.go

This file was deleted.

Loading

0 comments on commit d3f4ddb

Please sign in to comment.