Skip to content

Comments

fix: sqs builder#21

Merged
edgarfgp merged 5 commits intomainfrom
fix-sqs-builder
Dec 3, 2025
Merged

fix: sqs builder#21
edgarfgp merged 5 commits intomainfrom
fix-sqs-builder

Conversation

@edgarfgp
Copy link
Collaborator

@edgarfgp edgarfgp commented Dec 2, 2025

No description provided.

@edgarfgp edgarfgp marked this pull request as ready for review December 2, 2025 19:27
@edgarfgp edgarfgp requested a review from Copilot December 2, 2025 19:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request significantly enhances the SQS queue builder DSL by renaming operations for clarity and adding support for many additional AWS SQS queue properties that were previously unavailable.

Key Changes

  • Renamed messageRetention to retentionPeriod and delaySeconds to deliveryDelay for better API consistency
  • Added support for 9 new SQS properties: DeduplicationScope, EnforceSSL, FifoThroughputLimit, MaxMessageSizeBytes, ReceiveMessageWaitTime, RedriveAllowPolicy, RemovalPolicy, DataKeyReuse, and DeadLetterQueue
  • Standardized Duration-based operations to accept Duration objects instead of primitive numeric types for better type safety

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/SQS.fs Core implementation: expanded QueueConfig record with new fields, renamed operations (messageRetentionretentionPeriod, delaySecondsdeliveryDelay, FifoQueueFifo), added 9 new custom operations with full XML documentation
tests/SQSTests.fs New comprehensive test file covering FIFO configuration, encryption, deduplication scope, throughput limits, SSL enforcement, and message size settings
tests/FsCdk.Tests.fsproj Added SQSTests.fs to the test project compilation order
tests/AppTests.fs Updated usage example from messageRetention to retentionPeriod
docs/sns-sqs-messaging.fsx Updated all queue examples to use retentionPeriod instead of messageRetention
docs/lambda-production-defaults.fsx Updated custom DLQ example to use retentionPeriod
docs/index.fsx Updated queue examples to use retentionPeriod; documentation table still references delaySeconds instead of deliveryDelay

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +151
module FsCDK.Tests.SQSTests

open Expecto
open FsCDK
open Amazon.CDK
open Amazon.CDK.AWS.SQS

[<Tests>]
let sqs_queue_dsl_tests =
testList
"SQS queue DSL"
[ test "defaults constructId to queue name" {
let spec = queue "MyQueue" { () }

Expect.equal spec.QueueName "MyQueue" "QueueName should be set"
Expect.equal spec.ConstructId "MyQueue" "ConstructId should default to queue name"
}

test "uses custom constructId when provided" {
let spec = queue "MyQueue" { constructId "MyQueueConstruct" }

Expect.equal spec.ConstructId "MyQueueConstruct" "Custom constructId should be used"
}

test "configures FIFO queue" {
let spec = queue "MyQueue.fifo" { fifo true }

Expect.isTrue spec.Props.Fifo.Value "Queue should be configured as FIFO"
}

test "enables content-based deduplication" {
let spec =
queue "MyQueue.fifo" {
fifo true
contentBasedDeduplication true
}

Expect.isTrue spec.Props.ContentBasedDeduplication.Value "ContentBasedDeduplication should be enabled"
}

test "configures dead-letter queue reference" {
let spec = queue "MyQueue" { deadLetterQueue "MyDLQ" 3 }

// Note: The actual DLQ connection happens at stack build time
Expect.equal spec.QueueName "MyQueue" "Queue name should be set"
}

test "applies encryption when configured" {
let spec = queue "MyQueue" { encryption QueueEncryption.KMS_MANAGED }

Expect.equal spec.Props.Encryption.Value QueueEncryption.KMS_MANAGED "Encryption should be set"
}

test "applies deduplication scope for FIFO queues" {
let spec =
queue "MyQueue.fifo" {
fifo true
deduplicationScope DeduplicationScope.MESSAGE_GROUP
}

Expect.equal
spec.Props.DeduplicationScope.Value
DeduplicationScope.MESSAGE_GROUP
"DeduplicationScope should be set"
}

test "enforces SSL when configured" {
let spec = queue "MyQueue" { enforceSSL true }

Expect.isTrue spec.Props.EnforceSSL.Value "EnforceSSL should be true"
}

test "applies FIFO throughput limit" {
let spec =
queue "MyQueue.fifo" {
fifo true
fifoThroughputLimit FifoThroughputLimit.PER_MESSAGE_GROUP_ID
}

Expect.equal
spec.Props.FifoThroughputLimit.Value
FifoThroughputLimit.PER_MESSAGE_GROUP_ID
"FifoThroughputLimit should be set"
}

test "applies max message size bytes" {
let spec = queue "MyQueue" { maxMessageSizeBytes 65536.0 }

Expect.equal spec.Props.MaxMessageSizeBytes.Value 65536.0 "MaxMessageSizeBytes should be set"
}

test "applies removal policy" {
let spec = queue "MyQueue" { removalPolicy RemovalPolicy.DESTROY }

Expect.equal spec.Props.RemovalPolicy.Value RemovalPolicy.DESTROY "RemovalPolicy should be set"
}

test "combines multiple non-Duration configurations" {
let spec =
queue "MyQueue.fifo" {
constructId "MyFifoQueue"
fifo true
contentBasedDeduplication true
deduplicationScope DeduplicationScope.MESSAGE_GROUP
fifoThroughputLimit FifoThroughputLimit.PER_MESSAGE_GROUP_ID
enforceSSL true
maxMessageSizeBytes 131072.0
removalPolicy RemovalPolicy.RETAIN
}

Expect.equal spec.ConstructId "MyFifoQueue" "ConstructId should be set"
Expect.isTrue spec.Props.Fifo.Value "Fifo should be true"
Expect.isTrue spec.Props.ContentBasedDeduplication.Value "ContentBasedDeduplication should be true"

Expect.equal
spec.Props.DeduplicationScope.Value
DeduplicationScope.MESSAGE_GROUP
"DeduplicationScope should be set"

Expect.equal
spec.Props.FifoThroughputLimit.Value
FifoThroughputLimit.PER_MESSAGE_GROUP_ID
"FifoThroughputLimit should be set"

Expect.isTrue spec.Props.EnforceSSL.Value "EnforceSSL should be true"
Expect.equal spec.Props.MaxMessageSizeBytes.Value 131072.0 "MaxMessageSizeBytes should be set"
Expect.equal spec.Props.RemovalPolicy.Value RemovalPolicy.RETAIN "RemovalPolicy should be set"
}

test "optional settings remain unset when not provided" {
let spec = queue "SimpleQueue" { () }

Expect.isNull (box spec.Props.Fifo) "Fifo should be null when not configured"

Expect.isNull
(box spec.Props.ContentBasedDeduplication)
"ContentBasedDeduplication should be null when not configured"

Expect.isNull (box spec.Props.Encryption) "Encryption should be null when not configured"
Expect.isNull (box spec.Props.EnforceSSL) "EnforceSSL should be null when not configured"

Expect.isNull
(box spec.Props.FifoThroughputLimit)
"FifoThroughputLimit should be null when not configured"

Expect.isNull
(box spec.Props.MaxMessageSizeBytes)
"MaxMessageSizeBytes should be null when not configured"

Expect.isNull (box spec.Props.RemovalPolicy) "RemovalPolicy should be null when not configured"
} ]
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test file lacks coverage for several important operations that were added or modified in the SQS builder. Missing test coverage for:

  • retentionPeriod (renamed from messageRetention)
  • visibilityTimeout
  • deliveryDelay (renamed from delaySeconds)
  • dataKeyReuse
  • receiveMessageWaitTime
  • redriveAllowPolicy

Consider adding tests for these operations to ensure they correctly set the corresponding properties on QueueProps.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Dec 2, 2025

@edgarfgp I've opened a new pull request, #22, to work on those changes. Once the pull request is ready, I'll request review from you.

@edgarfgp edgarfgp merged commit 04597c2 into main Dec 3, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants