debian-forge-composer/internal/cloud/awscloud/maintenance_test.go
Tomáš Hozza 0b5bfa044f internal/awscloud: remove S3 presign client from AWS struct
This functionality is not needed any more, since it is provided by the
osbuild/images version of AWS.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-08-12 13:15:43 +02:00

31 lines
796 B
Go

package awscloud_test
import (
"testing"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/stretchr/testify/require"
"github.com/osbuild/osbuild-composer/internal/cloud/awscloud"
)
func TestEC2RemoveSnapshotAndDeregisterImage(t *testing.T) {
m := newEc2Mock(t)
aws := awscloud.NewForTest(m, nil, &s3mock{t, "bucket", "object-key"}, nil)
require.NotNil(t, aws)
err := aws.RemoveSnapshotAndDeregisterImage(&ec2types.Image{
ImageId: &m.imageId,
State: ec2types.ImageStateAvailable,
BlockDeviceMappings: []ec2types.BlockDeviceMapping{
{
Ebs: &ec2types.EbsBlockDevice{
SnapshotId: &m.snapshotId,
},
},
},
})
require.NoError(t, err)
require.Equal(t, 1, m.calledFn["DeleteSnapshot"])
require.Equal(t, 1, m.calledFn["DeregisterImage"])
}