-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/osbuild-service-maintenance: add test for filtering SIs
- Loading branch information
1 parent
04a5ca6
commit 661f39c
Showing
3 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
main "github.com/osbuild/osbuild-composer/cmd/osbuild-service-maintenance" | ||
"github.com/osbuild/osbuild-composer/internal/common" | ||
) | ||
|
||
func TestFilterReservations(t *testing.T) { | ||
reservations := []ec2types.Reservation{ | ||
{ | ||
Instances: []ec2types.Instance{ | ||
{ | ||
LaunchTime: common.ToPtr(time.Now().Add(-time.Hour * 24)), | ||
InstanceId: common.ToPtr("not filtered"), | ||
}, | ||
}, | ||
}, | ||
{ | ||
Instances: []ec2types.Instance{ | ||
{ | ||
LaunchTime: common.ToPtr(time.Now().Add(-time.Minute * 121)), | ||
InstanceId: common.ToPtr("not filtered"), | ||
}, | ||
}, | ||
}, | ||
{ | ||
Instances: []ec2types.Instance{ | ||
{ | ||
LaunchTime: common.ToPtr(time.Now().Add(-time.Minute * 119)), | ||
InstanceId: common.ToPtr("filtered"), | ||
}, | ||
}, | ||
}, | ||
{ | ||
Instances: []ec2types.Instance{ | ||
{ | ||
LaunchTime: common.ToPtr(time.Now()), | ||
InstanceId: common.ToPtr("filtered"), | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
instanceIDs := main.FilterReservations(reservations) | ||
require.Equal(t, []string{"not filtered", "not filtered"}, instanceIDs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package main | ||
|
||
var FilterReservations = filterReservations |