Skip to content

Commit

Permalink
remove unused methods and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aidan-canva committed Feb 12, 2025
1 parent e2d4998 commit 2de2fcf
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 75 deletions.
11 changes: 0 additions & 11 deletions api/v1alpha1/freight_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,6 @@ func (f *Freight) IsVerifiedIn(stage string) bool {
return verified
}

// IsVerifiedInAll returns whether the Freight has been verified in all
// Stages.
func (f *Freight) IsVerifiedInAll(stages []string) bool {
for _, s := range stages {
if !f.IsVerifiedIn(s) {
return false
}
}
return true
}

// IsApprovedFor returns whether the Freight has been approved for the specified
// Stage.
func (f *Freight) IsApprovedFor(stage string) bool {
Expand Down
63 changes: 0 additions & 63 deletions api/v1alpha1/freight_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,69 +234,6 @@ func TestFreight_IsVerifiedIn(t *testing.T) {
require.True(t, freight.IsVerifiedIn(testStage))
}

func TestFreight_IsVerifiedInAll(t *testing.T) {
testCases := []struct {
name string
freight Freight
stages []string
expected bool
}{
{
name: "Freight is not verified in any stage",
freight: Freight{
Status: FreightStatus{
VerifiedIn: map[string]VerifiedStage{},
},
},
stages: []string{"stage1", "stage2"},
expected: false,
},
{
name: "Freight is verified in all stages",
freight: Freight{
Status: FreightStatus{
VerifiedIn: map[string]VerifiedStage{
"stage1": {},
"stage2": {},
},
},
},
stages: []string{"stage1", "stage2"},
expected: true,
},
{
name: "Freight is verified in some stages",
freight: Freight{
Status: FreightStatus{
VerifiedIn: map[string]VerifiedStage{
"stage1": {},
},
},
},
stages: []string{"stage1", "stage2"},
expected: false,
},
{
name: "Freight is verified in all stages but not in the same order",
freight: Freight{
Status: FreightStatus{
VerifiedIn: map[string]VerifiedStage{
"stage2": {},
"stage1": {},
},
},
},
stages: []string{"stage1", "stage2"},
expected: true,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
require.Equal(t, testCase.expected, testCase.freight.IsVerifiedInAll(testCase.stages))
})
}
}

func TestFreight_IsApprovedFor(t *testing.T) {
const testStage = "fake-stage"
freight := &Freight{}
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/warehouse_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func TestWarehouse_ListFreight(t *testing.T) {
VerifiedIn: []string{testUpstreamStage, testUpstreamStage2},
VerifiedBefore: &metav1.Time{Time: time.Now().Add(-1 * time.Hour)},
},
assertions: func(t *testing.T, freight []Freight, err error) {
assertions: func(t *testing.T, _ []Freight, err error) {
require.ErrorContains(t, err, "unsupported AvailabilityStrategy")
},
},
Expand Down

0 comments on commit 2de2fcf

Please sign in to comment.