go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/_motor/providers/awsec2ebs/setup_test.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  //go:build debugtest
     5  // +build debugtest
     6  
     7  package awsec2ebs
     8  
     9  import (
    10  	"context"
    11  	"testing"
    12  
    13  	"github.com/aws/aws-sdk-go-v2/aws"
    14  	"github.com/aws/aws-sdk-go-v2/config"
    15  	"github.com/aws/aws-sdk-go-v2/service/ec2"
    16  	"github.com/stretchr/testify/assert"
    17  )
    18  
    19  func awsTestConfig() aws.Config {
    20  	cfg, err := config.LoadDefaultConfig(context.Background(),
    21  		config.WithSharedConfigProfile("mondoo-demo"),
    22  		config.WithRegion("us-east-1"),
    23  	)
    24  	if err != nil {
    25  		panic(err)
    26  	}
    27  
    28  	return cfg
    29  }
    30  
    31  func TestFindRecentSnapshot(t *testing.T) {
    32  	ec2svc := ec2.NewFromConfig(awsTestConfig())
    33  	e := Provider{scannerRegionEc2svc: ec2svc}
    34  	found, _ := e.FindRecentSnapshotForVolume(context.Background(), VolumeId{Id: "vol-0c04d709ea3e59096", Region: "us-east-1", Account: "185972265011"})
    35  	assert.Equal(t, found, true)
    36  	// found, _ = e.FindRecentSnapshotForVolume(context.Background(), VolumeId{Id: "vol-0d5df63d656ac4d9c", Region: "us-east-1", Account: "185972265011"})
    37  	// assert.Equal(t, found, true)
    38  }