diff options
author | Nick White <git@njw.name> | 2021-07-13 12:08:20 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-07-13 12:08:20 +0100 |
commit | 8c98574edd21759f1882d0ec4240f562039913fd (patch) | |
tree | aab37d5b9a1e39906a17a1d1e2cdd788d8f14444 /aws.go | |
parent | 45b0c3ed61b1a7b7d18090f483c5d9ff9cddec7b (diff) |
Fix up tests a bit
Diffstat (limited to 'aws.go')
-rw-r--r-- | aws.go | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -51,6 +51,7 @@ type AwsConn struct { downloader *s3manager.Downloader uploader *s3manager.Uploader wipequrl, prequrl, ocrpgqurl, analysequrl string + testqurl string wipstorageid string } @@ -128,6 +129,19 @@ func (a *AwsConn) Init() error { return nil } +// TestInit initialises extra aws services needed for running tests. +func (a *AwsConn) TestInit() error { + a.Logger.Println("Getting test queue URL") + result, err := a.sqssvc.GetQueueUrl(&sqs.GetQueueUrlInput{ + QueueName: aws.String(queueTest), + }) + if err != nil { + return errors.New(fmt.Sprintf("Error getting test queue URL: %s\n", err)) + } + a.testqurl = *result.QueueUrl + return nil +} + func (a *AwsConn) CheckQueue(url string, timeout int64) (Qmsg, error) { msgResult, err := a.sqssvc.ReceiveMessage(&sqs.ReceiveMessageInput{ MaxNumberOfMessages: aws.Int64(1), @@ -337,17 +351,7 @@ func (a *AwsConn) WIPStorageId() string { } func (a *AwsConn) TestQueueId() string { - // We don't bother saving the queue id in Init(), as it's only - // used for testing - a.Logger.Println("Getting test queue URL") - result, err := a.sqssvc.GetQueueUrl(&sqs.GetQueueUrlInput{ - QueueName: aws.String(queueTest), - }) - if err != nil { - a.Logger.Printf("Error getting test queue URL: %s\n", err) - return "" - } - return *result.QueueUrl + return a.testqurl } func (a *AwsConn) ListObjects(bucket string, prefix string) ([]string, error) { |