Skip to content

Commit d511180

Browse files
committed
land entry pkg change
1 parent d9f72cd commit d511180

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

extension/landprovider/github/land.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77

88
"github.com/uber-go/tally/v4"
9+
"github.com/uber/submitqueue/entity"
910
entitygithub "github.com/uber/submitqueue/entity/github"
1011
"github.com/uber/submitqueue/extension/landprovider"
1112
"go.uber.org/zap"
@@ -56,7 +57,7 @@ func NewLandProvider(params Params) landprovider.LandProvider {
5657
// Returns an error if entries contain more than one PR, since merging multiple PRs
5758
// is not idempotent — a partial failure leaves already-merged PRs in a state that
5859
// cannot be retried.
59-
func (l *landProvider) Land(ctx context.Context, queue string, entries []landprovider.LandEntry) error {
60+
func (l *landProvider) Land(ctx context.Context, queue string, entries []entity.LandEntry) error {
6061
l.metricsScope.Counter("land_started").Inc(1)
6162

6263
if err := validateSinglePR(entries); err != nil {

extension/landprovider/github/land_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func mergeHandler(t *testing.T, statusCode int, message string) http.HandlerFunc
4040
}
4141

4242
func TestLandProvider_Land(t *testing.T) {
43-
singleEntry := func(uri string) []landprovider.LandEntry {
44-
return []landprovider.LandEntry{{
43+
singleEntry := func(uri string) []entity.LandEntry {
44+
return []entity.LandEntry{{
4545
Strategy: entity.RequestLandStrategyRebase,
4646
Change: entity.Change{URIs: []string{uri}},
4747
}}
@@ -50,7 +50,7 @@ func TestLandProvider_Land(t *testing.T) {
5050
tests := []struct {
5151
name string
5252
handler http.HandlerFunc
53-
entries []landprovider.LandEntry
53+
entries []entity.LandEntry
5454
wantErr bool
5555
rejected bool
5656
}{

extension/landprovider/github/validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package github
33
import (
44
"fmt"
55

6-
"github.com/uber/submitqueue/extension/landprovider"
6+
"github.com/uber/submitqueue/entity"
77
)
88

99
// validateSinglePR ensures entries contain exactly one PR.
1010
// This implementation does not support batch landing because the GitHub merge API
1111
// operates on individual PRs, making multi-PR landing non-idempotent on retry.
12-
func validateSinglePR(entries []landprovider.LandEntry) error {
12+
func validateSinglePR(entries []entity.LandEntry) error {
1313
if len(entries) == 0 {
1414
return fmt.Errorf("no entries to land")
1515
}

extension/landprovider/github/validate_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,45 @@ import (
66
"github.com/stretchr/testify/assert"
77
"github.com/stretchr/testify/require"
88
"github.com/uber/submitqueue/entity"
9-
"github.com/uber/submitqueue/extension/landprovider"
109
)
1110

1211
func TestValidateSinglePR(t *testing.T) {
13-
validEntry := landprovider.LandEntry{
12+
validEntry := entity.LandEntry{
1413
Strategy: entity.RequestLandStrategyRebase,
1514
Change: entity.Change{URIs: []string{"github://uber/repo/1/abc123"}},
1615
}
1716

1817
tests := []struct {
1918
name string
20-
entries []landprovider.LandEntry
19+
entries []entity.LandEntry
2120
wantErr bool
2221
}{
2322
{
2423
name: "single entry single URI",
25-
entries: []landprovider.LandEntry{validEntry},
24+
entries: []entity.LandEntry{validEntry},
2625
},
2726
{
2827
// len(entries) == 0
2928
name: "no entries",
30-
entries: []landprovider.LandEntry{},
29+
entries: []entity.LandEntry{},
3130
wantErr: true,
3231
},
3332
{
3433
// totalURIs == 0
3534
name: "entry with no URIs",
36-
entries: []landprovider.LandEntry{{Strategy: entity.RequestLandStrategyRebase, Change: entity.Change{URIs: []string{}}}},
35+
entries: []entity.LandEntry{{Strategy: entity.RequestLandStrategyRebase, Change: entity.Change{URIs: []string{}}}},
3736
wantErr: true,
3837
},
3938
{
4039
// totalURIs > 1 via multiple entries
4140
name: "multiple entries",
42-
entries: []landprovider.LandEntry{validEntry, validEntry},
41+
entries: []entity.LandEntry{validEntry, validEntry},
4342
wantErr: true,
4443
},
4544
{
4645
// totalURIs > 1 via multiple URIs in one entry
4746
name: "multiple URIs in single entry",
48-
entries: []landprovider.LandEntry{{
47+
entries: []entity.LandEntry{{
4948
Strategy: entity.RequestLandStrategyRebase,
5049
Change: entity.Change{URIs: []string{"github://uber/repo/1/sha1", "github://uber/repo/2/sha2"}},
5150
}},
@@ -54,7 +53,7 @@ func TestValidateSinglePR(t *testing.T) {
5453
{
5554
// len(entries[0].Change.URIs) == 0 with URI in second entry
5655
name: "first entry empty second has URI",
57-
entries: []landprovider.LandEntry{
56+
entries: []entity.LandEntry{
5857
{Strategy: entity.RequestLandStrategyRebase, Change: entity.Change{URIs: []string{}}},
5958
validEntry,
6059
},

0 commit comments

Comments
 (0)