-
-
Notifications
You must be signed in to change notification settings - Fork 2
Added tests #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests #18
Conversation
WalkthroughThis pull request introduces several updates, including a newline addition in Changes
Sequence DiagramsequenceDiagram
participant Test as Component Test
participant AWS as AWS Resources
participant DB as PostgreSQL Database
Test->>AWS: Provision Resources
Test->>DB: Connect and Validate
DB-->>Test: Verify Database Existence
DB-->>Test: Verify Schema Existence
DB-->>Test: Verify User Grants
Test->>AWS: Teardown Resources
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require terratestWonderful, this rule succeeded.This rule require terratest status
|
/terratest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
♻️ Duplicate comments (2)
test/fixtures/stacks/catalog/usecase/user.yaml (1)
10-11
:⚠️ Potential issueSecurity Risk: Empty database password.
Empty passwords pose a significant security risk. Implement secure password management.
test/fixtures/stacks/catalog/aurora-postgres.yaml (1)
30-31
:⚠️ Potential issueSecurity Risk: Empty admin password.
Empty admin password is a critical security risk. Implement secure password management.
🧹 Nitpick comments (12)
test/fixtures/stacks/catalog/dns-delegated.yaml (2)
10-10
: Remove trailing spaces.There are trailing spaces at the end of line 10.
- request_acm_certificate: false + request_acm_certificate: false🧰 Tools
🪛 yamllint (1.35.1)
[error] 10-10: trailing spaces
(trailing-spaces)
1-10
: Consider documenting the test configuration.Since this is part of the test fixtures, consider adding comments to explain the purpose of this DNS delegation setup and why ACM certificate requests are disabled.
components: terraform: dns-delegated: + # Test fixture for DNS delegation testing + # ACM certificates disabled to simplify test setup metadata: component: dns-delegated🧰 Tools
🪛 yamllint (1.35.1)
[error] 10-10: trailing spaces
(trailing-spaces)
test/fixtures/atmos.yaml (1)
79-87
: Format the jq command for better readability.The command has trailing spaces and could be more readable with proper formatting.
- | jq '.[] | .components.terraform | to_entries | - map(select(.value.component == "component" and (.value.metadata.type != "abstract" or .value.metadata.type == null))) - | .[].key' + | jq '.[] | .components.terraform | to_entries | + map(select(.value.component == "component" and + (.value.metadata.type != "abstract" or .value.metadata.type == null) + )) | + .[].key'🧰 Tools
🪛 yamllint (1.35.1)
[error] 85-85: trailing spaces
(trailing-spaces)
[error] 86-86: trailing spaces
(trailing-spaces)
[error] 87-87: trailing spaces
(trailing-spaces)
test/fixtures/stacks/catalog/account-map.yaml (1)
33-46
: Consider providing default values for empty configurations.Several configuration maps and arrays are initialized as empty (
{}
or[]
). While this might be intentional for testing, it could lead to confusion or errors. Consider:
- Adding comments explaining why these are empty
- Providing example values in comments
- Adding validation to ensure required values are set before tests run
test/component_test.go (3)
162-162
: Fix the typo in variable nameclusterIdenitfier
.There is a typo in the variable name
clusterIdenitfier
. It should beclusterIdentifier
.Apply this diff to correct the typo:
- clusterIdenitfier := atm.Output(clusterComponent, "cluster_identifier") + clusterIdentifier := atm.Output(clusterComponent, "cluster_identifier")
96-97
: Rename variables for clarity in test assertions.The variable
schemaExistsInRdsInstance
is used to check the existence of a database, which can be misleading. Rename it todatabaseExistsInRdsInstance
for better readability.Apply this diff to rename the variable:
- schemaExistsInRdsInstance := GetWhetherDatabaseExistsInRdsPostgresInstance(t, ...) - assert.True(t, schemaExistsInRdsInstance) + databaseExistsInRdsInstance := GetWhetherDatabaseExistsInRdsPostgresInstance(t, ...) + assert.True(t, databaseExistsInRdsInstance)Also applies to: 173-174
227-241
: Enhance database existence check with proper query.The
GetWhetherDatabaseExistsInRdsPostgresInstanceE
function currently attempts to determine if a database exists by connecting to it. A more reliable method is to connect to a default database and query thepg_database
catalog.Apply this diff to improve the function:
func GetWhetherDatabaseExistsInRdsPostgresInstanceE(t *testing.T, dbUrl string, dbPort int32, dbUsername string, dbPassword string, databaseName string) (bool, error) { - connectionString := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s", dbUrl, dbPort, dbUsername, dbPassword, databaseName) + connectionString := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=postgres", dbUrl, dbPort, dbUsername, dbPassword) db, connErr := sql.Open("pgx", connectionString) if connErr != nil { return false, connErr } defer db.Close() + var exists bool + query := "SELECT EXISTS(SELECT 1 FROM pg_database WHERE datname = $1);" + err := db.QueryRow(query, databaseName).Scan(&exists) + if err != nil { + return false, err + } + return exists, nil - return true, nil }test/fixtures/stacks/catalog/vpc.yaml (2)
8-10
: Consider adding more Availability Zones for better resilience.Currently only using AZs 'b' and 'c'. Consider including AZ 'a' for better availability.
availability_zones: + - "a" - "b" - "c"
18-18
: Security consideration: VPC flow logs are disabled.Consider enabling VPC flow logs for security monitoring and troubleshooting, even in test environments.
- vpc_flow_logs_enabled: false + vpc_flow_logs_enabled: truetest/fixtures/stacks/catalog/aurora-postgres.yaml (2)
23-23
: Consider upgrading PostgreSQL version.Version 13.15 is not the latest. Consider using PostgreSQL 14 or 15 for new deployments.
- engine_version: "13.15" # Latest supported version as of 08/28/2023 + engine_version: "15.4" # Replace with latest supported version
11-12
: Enable deletion protection for database safety.Consider enabling deletion protection to prevent accidental database deletion.
- deletion_protection: false + deletion_protection: truetest/fixtures/vendor.yaml (1)
13-18
: Consider using YAML anchors to reduce repetition.The included_paths configuration is identical across all components. Consider using YAML anchors and aliases to make the configuration more maintainable.
Example refactor:
spec: sources: + # Define the common paths once + common: &common_paths + included_paths: + - "**/*.tf" + - "**/*.md" + - "**/*.tftmpl" + - "**/modules/**" + excluded_paths: [] + - component: "account-map" source: github.com/cloudposse/terraform-aws-components.git//modules/account-map?ref={{.Version}} version: 1.520.0 targets: - "components/terraform/account-map" - included_paths: - - "**/*.tf" - - "**/*.md" - - "**/*.tftmpl" - - "**/modules/**" - excluded_paths: [] + <<: *common_pathsAlso applies to: 25-30, 37-42, 49-54, 61-66, 72-77
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
test/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (19)
src/outputs.tf
(1 hunks)src/remote-state.tf
(1 hunks)test/.gitignore
(1 hunks)test/component_test.go
(1 hunks)test/fixtures/atmos.yaml
(1 hunks)test/fixtures/stacks/catalog/account-map.yaml
(1 hunks)test/fixtures/stacks/catalog/aurora-postgres.yaml
(1 hunks)test/fixtures/stacks/catalog/dns-delegated.yaml
(1 hunks)test/fixtures/stacks/catalog/dns-primary.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/database.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/grant.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/schema.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/user.yaml
(1 hunks)test/fixtures/stacks/catalog/vpc.yaml
(1 hunks)test/fixtures/stacks/orgs/default/test/_defaults.yaml
(1 hunks)test/fixtures/stacks/orgs/default/test/tests.yaml
(1 hunks)test/fixtures/vendor.yaml
(1 hunks)test/go.mod
(1 hunks)test/run.sh
(0 hunks)
💤 Files with no reviewable changes (1)
- test/run.sh
✅ Files skipped from review due to trivial changes (3)
- src/outputs.tf
- test/.gitignore
- src/remote-state.tf
🧰 Additional context used
🪛 yamllint (1.35.1)
test/fixtures/stacks/catalog/dns-delegated.yaml
[error] 10-10: trailing spaces
(trailing-spaces)
test/fixtures/atmos.yaml
[error] 85-85: trailing spaces
(trailing-spaces)
[error] 86-86: trailing spaces
(trailing-spaces)
[error] 87-87: trailing spaces
(trailing-spaces)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Mergify Merge Protections
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🔇 Additional comments (22)
test/fixtures/stacks/catalog/dns-primary.yaml (2)
7-9
: LGTM! Good choice of domain for testing.Using example.net is appropriate for test fixtures as it's a reserved domain for testing purposes.
9-9
: Verify if empty record_config is intentional.The empty record_config array might need to be populated depending on your test requirements.
test/fixtures/stacks/catalog/dns-delegated.yaml (1)
7-9
: LGTM! Proper DNS delegation setup.The zone configuration correctly references the parent domain from dns-primary.yaml, establishing a proper testing hierarchy with test.example.net.
test/go.mod (1)
17-97
: Dependencies look well-structuredThe indirect dependencies are properly marked and align well with the project's purpose (AWS Aurora PostgreSQL testing). The AWS SDK and database-related dependencies are appropriate for the functionality.
test/fixtures/atmos.yaml (6)
1-18
: LGTM! Well-documented configuration loading behavior.The configuration loading priorities and base path behavior are clearly documented, making it easy for users to understand how the configuration works.
34-50
: LGTM! Well-structured stacks configuration.The stacks configuration follows best practices with clear path organization and logical naming patterns.
51-54
: LGTM! Clear workflow path configuration.
56-61
: LGTM! Container-friendly logging configuration.Good choice directing logs to stdout, which is ideal for containerized environments.
62-65
: LGTM! Clear settings configuration.
66-78
: LGTM! Comprehensive template configuration with good documentation.test/fixtures/stacks/catalog/account-map.yaml (2)
1-10
: LGTM! Well-structured component configuration.The component configuration follows good practices with clear workspace naming and appropriate variable scoping for root-level infrastructure.
23-32
: Verify TEST_ACCOUNT_ID environment variable.The configuration relies on the
TEST_ACCOUNT_ID
environment variable, but there's no clear validation mechanism. Consider adding validation to ensure the variable is set correctly before proceeding with tests.test/fixtures/stacks/orgs/default/test/_defaults.yaml (4)
1-3
: LGTM! Import configuration is properly structured.The import of the account-map catalog is correctly configured for managing AWS account configurations.
4-14
: Consider DRYing up the backend configurations.The backend and remote_state_backend configurations are identical. Consider extracting the common configuration into a reusable variable or template.
Verify environment variables in CI/CD pipeline.
The configuration relies on
TEST_STATE_DIR
andTEST_SUITE_NAME
environment variables.
41-71
:⚠️ Potential issueResolve inconsistent EKS configuration.
There's a contradiction in the EKS configuration:
- Line 49:
eks: true
- Line 55:
tags.eks: false
Please align these values to prevent confusion.
Verify TEST_ACCOUNT_ID handling.
The configuration heavily relies on the TEST_ACCOUNT_ID environment variable. Ensure proper error handling when this variable is not set.
15-40
: LGTM! Well-structured variable and label configuration.The label ordering and descriptor formats follow AWS best practices. The test stage configuration is appropriate for test fixtures.
✅ Verification successful
Label configuration is correctly implemented as a centralized default
The label_order and descriptor_formats are properly defined in _defaults.yaml and inherited by other configurations through the import system. This centralized approach follows infrastructure-as-code best practices by:
- Maintaining a single source of truth for label configurations
- Using proper inheritance through the import system
- Aligning with the atmos.yaml stack naming patterns
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify consistency of label configuration across the repository # Check for consistent label ordering in other configuration files echo "Checking for consistent label ordering across configurations..." fd -e yaml -e yml . test/fixtures -x grep -l "label_order:" {} \; # Verify descriptor format usage echo "Checking descriptor format usage..." rg -l "format:.*%v.*%v"Length of output: 420
Script:
#!/bin/bash # Check for files that might reference or import this defaults file echo "Checking for files referencing _defaults.yaml..." rg -l "_defaults\.ya?ml" # Check for other YAML files in the same directory structure echo "Checking for other YAML files in the test fixtures..." fd -e yaml -e yml . test/fixtures/stacks/orgs/default/test/Length of output: 441
Script:
#!/bin/bash # Check the content of atmos.yaml to understand how defaults are used echo "Checking atmos.yaml content..." cat test/fixtures/atmos.yaml # Also check tests.yaml to see if it overrides any defaults echo -e "\nChecking tests.yaml content..." cat test/fixtures/stacks/orgs/default/test/tests.yamlLength of output: 4383
test/fixtures/stacks/catalog/usecase/database.yaml (1)
2-8
:⚠️ Potential issueFix inconsistent indentation in YAML file.
The indentation in the YAML file is inconsistent, which may lead to parsing errors. Ensure that indentation levels are consistent according to YAML standards.
Apply this diff to correct the indentation:
components: - terraform: - aurora-postgres-resources/database: - metadata: - component: aurora-postgres-resources - vars: - enabled: true - additional_databases: ["test-db"] + terraform: + aurora-postgres-resources/database: + metadata: + component: aurora-postgres-resources + vars: + enabled: true + additional_databases: ["test-db"]Likely invalid or redundant comment.
test/fixtures/stacks/catalog/usecase/schema.yaml (1)
2-10
:⚠️ Potential issueFix inconsistent indentation in YAML file.
The indentation in the YAML file is inconsistent, which may lead to parsing errors. Ensure that indentation levels are consistent throughout the file.
Apply this diff to correct the indentation:
components: - terraform: - aurora-postgres-resources/schema: - metadata: - component: aurora-postgres-resources - vars: - enabled: true - additional_schemas: - test-schema: - database: postgres + terraform: + aurora-postgres-resources/schema: + metadata: + component: aurora-postgres-resources + vars: + enabled: true + additional_schemas: + test-schema: + database: postgresLikely invalid or redundant comment.
test/fixtures/stacks/orgs/default/test/tests.yaml (1)
1-10
: LGTM! Well-structured import hierarchy.The imports follow a logical dependency order from infrastructure (DNS, VPC) to database components and use cases.
test/fixtures/stacks/catalog/vpc.yaml (1)
11-15
: Verify the networking configuration.Public subnets are enabled but NAT is disabled. This might cause connectivity issues for resources in private subnets requiring internet access.
test/fixtures/vendor.yaml (2)
1-5
: LGTM! Well-structured configuration header.The configuration follows standard Kubernetes-style YAML structure with clear API version, kind, and metadata definitions.
7-77
: Verify component dependencies for testing.Let's ensure all required components for testing Aurora Postgres are included.
✅ Verification successful
All required components are properly configured
The vendor.yaml configuration correctly includes all necessary components for testing:
- Core infrastructure components (account-map, dns-primary)
- Network components (vpc, dns-delegated)
- Database components (aurora-postgres, aurora-postgres-resources)
The component versions and configurations align with the test fixtures structure in
test/fixtures/stacks/catalog/
.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential missing components by analyzing terraform configurations # Look for terraform module references in the test directory echo "Checking for terraform module references in tests..." rg -t tf 'module\s+"[^"]+"\s+{' test/ # Look for potential missing components in source code echo "Checking for potential component dependencies in source..." rg -t tf 'source\s+=\s+"[^"]+"' src/Length of output: 1217
Script:
#!/bin/bash # Search for module configurations in test files with proper regex echo "Checking test configurations..." rg -t tf 'module\s+".+"' test/ # Check for any additional provider configurations in test echo "Checking provider configurations..." rg -t tf 'provider\s+".+"' test/ # Check for specific resource types that might indicate missing dependencies echo "Checking resource configurations..." rg -t tf 'resource\s+".+"' test/Length of output: 337
Script:
#!/bin/bash # Check directory structure and find terraform-related files echo "Directory structure:" find . -type d -name "test" -o -name "tests" echo -e "\nSearching for Terraform files:" fd -e tf -e tftest.hcl -e tfvars echo -e "\nChecking specific test fixtures directory:" ls -R test/fixtures/Length of output: 1143
/terratest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
test/go.mod (1)
5-13
:⚠️ Potential issueInvalid Dependency Versions: Future Timestamp and Testify Version
The dependency forgithub.com/cloudposse/test-helpers
is specified with a version string that includes a future timestamp (v0.16.1-0.20250214180823-8864e655b58f
), which could potentially cause build instability. Similarly, the dependencygithub.com/stretchr/testify
is set tov1.9.0
, which, as noted in previous reviews, may not yet be available or could be invalid. Please verify these versions and update them to stable, officially released versions if necessary.
🧹 Nitpick comments (2)
test/component_test.go (2)
31-31
: Consider handling potential errors instead of discarding them.Here, the call to
DeployAtmosComponent
captures theoptions
but discards the error. While ignoring errors is sometimes acceptable for test scaffolding, consider checking or asserting the returned error for clarity and better maintainability.- options, _ := s.DeployAtmosComponent(s.T(), component, stack, &inputs) + options, err := s.DeployAtmosComponent(s.T(), component, stack, &inputs) + assert.NoError(s.T(), err)Also applies to: 73-73, 125-125, 167-167, 194-194
206-206
: Remove unused variable to clean up the code.
awsRegion
is declared but never used. Removing it will eliminate unused variable warnings and clarify the method’s intent.- const awsRegion = "us-east-2"
🧰 Tools
🪛 golangci-lint (1.62.2)
206-206: const
awsRegion
is unused(unused)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
test/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (11)
test/.gitignore
(1 hunks)test/component_test.go
(1 hunks)test/fixtures/stacks/catalog/usecase/database.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/disabled.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/grant.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/schema.yaml
(1 hunks)test/fixtures/stacks/catalog/usecase/user.yaml
(1 hunks)test/fixtures/stacks/orgs/default/test/_defaults.yaml
(1 hunks)test/fixtures/stacks/orgs/default/test/tests.yaml
(1 hunks)test/fixtures/vendor.yaml
(1 hunks)test/go.mod
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- test/.gitignore
- test/fixtures/stacks/catalog/usecase/database.yaml
- test/fixtures/vendor.yaml
- test/fixtures/stacks/catalog/usecase/user.yaml
- test/fixtures/stacks/catalog/usecase/grant.yaml
- test/fixtures/stacks/orgs/default/test/_defaults.yaml
🧰 Additional context used
🪛 golangci-lint (1.62.2)
test/component_test.go
206-206: const awsRegion
is unused
(unused)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Mergify Merge Protections
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🔇 Additional comments (7)
test/fixtures/stacks/orgs/default/test/tests.yaml (1)
1-12
: Approval: YAML Import Configuration is Well-StructuredThe YAML file defines a clear and concise list of modules to be imported. The indentation and list formatting are correct, and the order suggests intentional grouping (default settings, DNS modules, VPC, Aurora PostgreSQL, and various use case modules). This configuration should integrate seamlessly with the test framework.
test/component_test.go (2)
49-50
: Align data type and assertion for database port.This code stores
dbPort
as afloat64
but asserts that it “should be an int,” risking confusion or casting errors. Either update the assertion message or cast thedbPort
to an integer type explicitly. This is a reiteration of a past review comment regarding port data type handling.- dbPort, ok := configMap["port"].(float64) - assert.True(s.T(), ok, "database_port should be an int") + dbPortFloat, ok := configMap["port"].(float64) + assert.True(s.T(), ok, "database_port should be a float64") + dbPort := int32(dbPortFloat)Also applies to: 91-92, 140-141, 182-183
197-198
:❓ Verification inconclusive
Confirm that the underlying SQL parameter binding has been fixed.
Previously, we flagged issues with parameter binding and
Scan
arguments inGetWhetherGrantsExistsInRdsPostgresInstance
. Since the implementation is not visible here, please verify that the function no longer encloses$1
in quotes and thatScan
arguments match the retrieved columns.
🏁 Script executed:
#!/bin/bash # Search for the function definition and confirm no single quotes around $1 # and that the SELECT statement and Scan arguments match the columns. ast-grep --pattern $'func GetWhetherGrantsExistsInRdsPostgresInstance($_, $_, $_, $_, $_, $_, $_) { $$$ }' rg -A 5 "SELECT" | rg "GetWhetherGrantsExistsInRdsPostgresInstance"Length of output: 173
Please confirm SQL parameter binding and Scan arguments in GetWhetherGrantsExistsInRdsPostgresInstance.
It appears our initial automated search did not produce output, so I'm unable to verify that the fix is fully implemented. Please manually check that the function’s SQL query does not enclose the parameter placeholder (e.g.
$1
) in quotes and that theScan
arguments correctly match the columns returned by your SELECT statement.
- Verify that there are no extraneous quotes around SQL placeholders.
- Confirm that the columns selected match the arguments passed to
Scan
.test/fixtures/stacks/catalog/usecase/disabled.yaml (1)
1-9
: Looks good to me.The disabled state is clearly expressed and consistent with your test approach.
test/fixtures/stacks/catalog/usecase/schema.yaml (1)
1-10
: No issues detected.Defining the additional schema and database mapping is clear and aligns with the associated test cases.
test/go.mod (2)
1-3
: Module Declaration and Go Version: Verify Go Version
The module declaration is correct. However, please confirm that the specified Go version"1.23.0"
is stable and officially released. If it turns out that this version is not yet supported or validated in your environment, consider reverting to a supported version (for example,"1.22.0"
).
15-124
: Indirect Dependencies Overview
This block lists numerous indirect dependencies that appear to be auto-generated (e.g., viago mod tidy
). Overall, they look standard; however, ensure that all these versions are compatible with your project requirements and pass your security and stability checks as part of your build process.
/terratest |
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
test/go.mod (2)
3-3
:⚠️ Potential issueFix Go version specification.
Go version 1.23.0 does not exist yet. The latest stable version is 1.22.0. This will cause build failures.
-go 1.23.0 +go 1.22.0
11-11
:⚠️ Potential issueUpdate testify dependency version.
The version v1.9.0 of the testify package doesn't exist yet. The latest stable version is v1.8.4.
- github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.8.4
🧹 Nitpick comments (3)
test/component_test.go (3)
50-50
: Correct assertion message fordbPort
.The assertion message refers to "database_port" but the variable is named "port", and it's being checked as a float64 but the message mentions "an int".
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
52-52
: Fix typo in function name.The helper function name has a typo: "AssertPotgresqlDatabaseExists" should be "AssertPostgresqlDatabaseExists".
Consider opening an issue to fix the typo in the helper function name, but this doesn't affect functionality.
206-206
: Remove unused constant.The constant
awsRegion
is declared but not used in theTestDisabled
function.func (s *ComponentSuite) TestDisabled() { const component = "aurora-postgres-resources/disabled" const stack = "default-test" - const awsRegion = "us-east-2" s.VerifyEnabledFlag(component, stack, nil) }
🧰 Tools
🪛 golangci-lint (1.62.2)
206-206: const
awsRegion
is unused(unused)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
test/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (4)
test/component_test.go
(1 hunks)test/fixtures/atmos.yaml
(1 hunks)test/fixtures/vendor.yaml
(1 hunks)test/go.mod
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- test/fixtures/vendor.yaml
- test/fixtures/atmos.yaml
🧰 Additional context used
🪛 golangci-lint (1.62.2)
test/component_test.go
206-206: const awsRegion
is unused
(unused)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🔇 Additional comments (6)
test/component_test.go (6)
92-92
: Correct assertion message fordbPort
.The assertion message refers to "database_port" but the variable is named "port", and it's being checked as a float64 but the message mentions "an int".
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
141-141
: Correct assertion message fordbPort
.The assertion message refers to "database_port" but the variable is named "port", and it's being checked as a float64 but the message mentions "an int".
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
183-183
: Correct assertion message fordbPort
.The assertion message refers to "database_port" but the variable is named "port", and it's being checked as a float64 but the message mentions "an int".
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
94-94
: Fix typo in function name.The helper function name has a typo: "AssertPotgresqlSchemaExists" should be "AssertPostgresqlSchemaExists".
Consider opening an issue to fix the typo in the helper function name, but this doesn't affect functionality.
197-197
: Fix typo in function name.The helper function name has a typo: "AssertPotgresqlGrantsExists" should be "AssertPostgresqlGrantsExists".
Consider opening an issue to fix the typo in the helper function name, but this doesn't affect functionality.
211-233
: Great test suite setup and dependencies management.The test suite is well-structured with proper dependency management for VPC, DNS delegation, and Aurora PostgreSQL. The tests cover all important aspects like database, schema, user, grants, and the disabled flag functionality.
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
/terratest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
test/go.mod (1)
3-3
:⚠️ Potential issueCorrect the Go version specification
Go version 1.23.0 does not exist yet. The latest stable version is 1.22.0. This will cause build failures.
-go 1.23.0 +go 1.22.0
🧹 Nitpick comments (1)
test/component_test.go (1)
204-207
: Remove unused constant in TestDisabledThe
awsRegion
constant is defined but never used in this test function.func (s *ComponentSuite) TestDisabled() { const component = "aurora-postgres-resources/disabled" const stack = "default-test" - const awsRegion = "us-east-2" s.VerifyEnabledFlag(component, stack, nil) }
🧰 Tools
🪛 golangci-lint (1.62.2)
207-207: const
awsRegion
is unused(unused)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
test/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (3)
test/component_test.go
(1 hunks)test/fixtures/stacks/catalog/usecase/grant.yaml
(1 hunks)test/go.mod
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- test/fixtures/stacks/catalog/usecase/grant.yaml
🧰 Additional context used
🪛 golangci-lint (1.62.2)
test/component_test.go
207-207: const awsRegion
is unused
(unused)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Mergify Merge Protections
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🔇 Additional comments (11)
test/go.mod (1)
11-11
:✅ Verification successful
Verify the testify version
The testify version v1.9.0 may not exist. Please verify this version is correct.
🏁 Script executed:
#!/bin/bash # Check if the testify version exists echo "Checking if github.com/stretchr/testify v1.9.0 exists..." curl -s "https://proxy.golang.org/github.com/stretchr/testify/@v/v1.9.0.info" | grep -q "404" && echo "Version v1.9.0 does not exist" || echo "Version v1.9.0 exists" # Check the latest release version echo -e "\nLatest release version:" curl -s "https://api.github.com/repos/stretchr/testify/releases/latest" | grep "tag_name"Length of output: 443
Confirmed: Testify Dependency Version Exists
The dependency in
test/go.mod
(line 11) usinggithub.com/stretchr/testify v1.9.0
has been verified via the Go proxy and indeed exists. Note that the latest release isv1.10.0
; please consider if an upgrade aligns with our project requirements.test/component_test.go (10)
50-50
: Correct the assertion message for dbPortThe assertion message doesn't match the variable type being checked. dbPort is a float64, but the message implies it should be an int.
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
92-92
: Correct the assertion message for dbPortThe assertion message doesn't match the variable type being checked. dbPort is a float64, but the message implies it should be an int.
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
141-141
: Correct the assertion message for dbPortThe assertion message doesn't match the variable type being checked. dbPort is a float64, but the message implies it should be an int.
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
184-184
: Correct the assertion message for dbPortThe assertion message doesn't match the variable type being checked. dbPort is a float64, but the message implies it should be an int.
- assert.True(s.T(), ok, "database_port should be an int") + assert.True(s.T(), ok, "port should be a float64")
20-56
: LGTM: TestDatabase implementationThe TestDatabase function correctly tests database creation by:
- Deploying the Aurora PostgreSQL database component with a randomly generated database name
- Retrieving configuration from the cluster component
- Verifying database existence using AssertPotgresqlDatabaseExists
- Running a drift test to ensure the deployed state matches the expected state
The logic is well-structured and includes proper cleanup with defer.
58-98
: LGTM: TestSchema implementationThe TestSchema function correctly tests schema creation by:
- Deploying the schema component with a randomly generated schema name
- Retrieving configuration from the cluster component
- Verifying schema existence using AssertPotgresqlSchemaExists
- Running a drift test to ensure the deployed state matches the expected state
The logic is well-structured and includes proper cleanup with defer.
100-147
: LGTM: TestUser implementationThe TestUser function correctly tests user creation and permissions by:
- Deploying the user component with randomly generated user and service names
- Retrieving configuration from the cluster component
- Verifying user access to the database using AssertPotgresqlDatabaseExists
- Running a drift test to ensure the deployed state matches the expected state
The logic is well-structured and includes proper cleanup with defer.
149-202
: Good implementation of TestGrantThe TestGrant function is well-implemented but currently skipped due to a known issue (tracked in issue #17). The test logic properly:
- Creates a user with no initial grants
- Adds grants in a second deployment step
- Verifies grants using AssertPotgresqlGrantsExists
Good practice to include a skip message with a link to the relevant issue for future reference.
212-234
: LGTM: TestRunSuite implementationThe TestRunSuite function provides a well-structured setup for running the test suite:
- Creates a new ComponentSuite instance
- Adds dependencies for VPC, DNS delegation, and Aurora PostgreSQL
- Uses random values for subdomain and cluster name to ensure test isolation
- Passes the suite to helper.Run for execution
This approach ensures repeatable, isolated test runs.
198-199
:❓ Verification inconclusive
Verify the implementation of AssertPotgresqlGrantsExists
Given the past review comment about SQL parameter binding and Scan arguments in grant existence check, please verify that the
AssertPotgresqlGrantsExists
function has been properly implemented.
🏁 Script executed:
#!/bin/bash # Look for the implementation of AssertPotgresqlGrantsExists echo "Searching for the implementation of AssertPotgresqlGrantsExists function..." ast-grep --pattern $'func AssertPotgresqlGrantsExists(t testing.TB, $$$) bool { $$$ }'Length of output: 250
I'll run an additional search using ripgrep to locate any implementation of
AssertPotgresqlGrantsExists
that might not have matched the initial AST grep pattern. This will help us ensure whether the function exists and, if so, review its implementation details concerning SQL parameter binding and Scan arguments.Once we have the output from this command, we can decide how to proceed with verifying the function's correctness.
🏁 Script executed:
#!/bin/bash echo "Searching for AssertPotgresqlGrantsExists implementation using ripgrep..." rg "func AssertPotgresqlGrantsExists" -n .Length of output: 201
ACTION REQUIRED: Manual Verification Needed for
AssertPotgresqlGrantsExists
ImplementationOur automated searches (using both AST-grep and ripgrep) did not locate an implementation for
AssertPotgresqlGrantsExists
in the repository. Given the past concerns about SQL parameter binding and Scan arguments in the grant existence check, please manually verify that the function implementation in theawshelper
package meets the intended specifications. Specifically:
- Confirm that SQL parameters are bound safely to avoid injection issues.
- Verify that the Scan arguments correctly map to the SQL query results.
These changes were released in v1.536.1. |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require terratestWonderful, this rule succeeded.This rule require terratest status
|
what
Summary by CodeRabbit
New Features
Improvements
Documentation
Chores
.gitignore
to exclude temporary and environment-specific files.