-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c802c8
commit a8006fb
Showing
13 changed files
with
199 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package gosqs | ||
|
||
import ( | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/Admiral-Piett/goaws/app/interfaces" | ||
|
||
"github.com/Admiral-Piett/goaws/app/models" | ||
"github.com/Admiral-Piett/goaws/app/utils" | ||
|
||
"github.com/Admiral-Piett/goaws/app" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func DeleteQueueV1(req *http.Request) (int, interfaces.AbstractResponseBody) { | ||
requestBody := models.NewDeleteQueueRequest() | ||
ok := utils.REQUEST_TRANSFORMER(requestBody, req, false) | ||
if !ok { | ||
log.Error("Invalid Request - DeleteQueueV1") | ||
return createErrorResponseV1(ErrInvalidParameterValue.Type) | ||
} | ||
|
||
uriSegments := strings.Split(requestBody.QueueUrl, "/") | ||
queueName := uriSegments[len(uriSegments)-1] | ||
|
||
log.Infof("Deleting Queue: %s", queueName) | ||
|
||
app.SyncQueues.Lock() | ||
delete(app.SyncQueues.Queues, queueName) | ||
app.SyncQueues.Unlock() | ||
|
||
respStruct := models.DeleteQueueResponse{ | ||
Xmlns: models.BASE_XMLNS, | ||
Metadata: models.BASE_RESPONSE_METADATA, | ||
} | ||
return http.StatusOK, respStruct | ||
} |
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 @@ | ||
package gosqs |
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
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
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
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
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,92 @@ | ||
package smoke_tests | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/gavv/httpexpect/v2" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/sqs" | ||
|
||
"github.com/Admiral-Piett/goaws/app/utils" | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/config" | ||
|
||
"github.com/Admiral-Piett/goaws/app" | ||
"github.com/stretchr/testify/assert" | ||
|
||
af "github.com/Admiral-Piett/goaws/app/fixtures" | ||
) | ||
|
||
func Test_DeleteQueueV1_json(t *testing.T) { | ||
server := generateServer() | ||
defer func() { | ||
server.Close() | ||
utils.ResetResources() | ||
}() | ||
|
||
sdkConfig, _ := config.LoadDefaultConfig(context.TODO()) | ||
sdkConfig.BaseEndpoint = aws.String(server.URL) | ||
sqsClient := sqs.NewFromConfig(sdkConfig) | ||
|
||
qName := "unit-queue1" | ||
sqsClient.CreateQueue(context.TODO(), &sqs.CreateQueueInput{ | ||
QueueName: &qName, | ||
}) | ||
|
||
qUrl := fmt.Sprintf("%s/%s", af.BASE_URL, qName) | ||
_, err := sqsClient.DeleteQueue(context.TODO(), &sqs.DeleteQueueInput{ | ||
QueueUrl: &qUrl, | ||
}) | ||
|
||
assert.Nil(t, err) | ||
|
||
app.SyncQueues.Lock() | ||
defer app.SyncQueues.Unlock() | ||
|
||
targetQueue, ok := app.SyncQueues.Queues["unit-queue1"] | ||
assert.False(t, ok) | ||
assert.Nil(t, targetQueue) | ||
} | ||
|
||
func Test_DeleteQueueV1_xml(t *testing.T) { | ||
server := generateServer() | ||
defer func() { | ||
server.Close() | ||
utils.ResetResources() | ||
}() | ||
|
||
e := httpexpect.Default(t, server.URL) | ||
|
||
sdkConfig, _ := config.LoadDefaultConfig(context.TODO()) | ||
sdkConfig.BaseEndpoint = aws.String(server.URL) | ||
sqsClient := sqs.NewFromConfig(sdkConfig) | ||
|
||
qName := "unit-queue1" | ||
sqsClient.CreateQueue(context.TODO(), &sqs.CreateQueueInput{ | ||
QueueName: &qName, | ||
}) | ||
|
||
qUrl := fmt.Sprintf("%s/%s", af.BASE_URL, qName) | ||
|
||
e.POST("/"). | ||
WithForm(struct { | ||
Action string `xml:"Action"` | ||
QueueUrl string `xml:"QueueUrl"` | ||
}{ | ||
Action: "DeleteQueue", | ||
QueueUrl: qUrl, | ||
}). | ||
Expect(). | ||
Status(http.StatusOK). | ||
Body().Raw() | ||
|
||
app.SyncQueues.Lock() | ||
defer app.SyncQueues.Unlock() | ||
|
||
targetQueue, ok := app.SyncQueues.Queues["unit-queue1"] | ||
assert.False(t, ok) | ||
assert.Nil(t, targetQueue) | ||
} |
Oops, something went wrong.