Skip to content

chore: adds some tests #13

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

Merged
merged 1 commit into from
May 15, 2025
Merged

chore: adds some tests #13

merged 1 commit into from
May 15, 2025

Conversation

pandeymangg
Copy link
Contributor

This pull request introduces several updates to the FormbricksSDK codebase, focusing on improving test coverage, enhancing the flexibility of the APIClient, and refining the SonarQube configuration. The most notable changes include making the URLSession injectable for testing, adding comprehensive unit tests for APIClient and other components, and updating SonarQube exclusions.

Enhancements to APIClient:

  • Made URLSession injectable by adding a session parameter to the APIClient initializer, defaulting to .shared. This change improves testability by allowing the use of mock sessions during testing. (Sources/FormbricksSDK/Networking/Base/APIClient.swift, Sources/FormbricksSDK/Networking/Base/APIClient.swiftL5-R11)

Expanded Test Coverage:

SonarQube Configuration:

  • Updated sonar.coverage.exclusions to exclude additional files (HTTPStatusCode.swift and EncodableRequest.swift) from coverage analysis, ensuring a more focused code quality assessment. (sonar-project.properties, sonar-project.propertiesL18-R18)

@pandeymangg pandeymangg requested review from mattinannt and Copilot May 15, 2025 16:37
Copy link

@Copilot 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 PR focuses on enhancing test coverage, improving testability of APIClient through URLSession injection, and refining SonarQube configuration for a more accurate static analysis.

  • Improved flexibility of APIClient by making URLSession injectable.
  • Expanded unit tests for APIClient, UpdateQueue, and API endpoints.
  • Updated sonar.coverage.exclusions to omit specified files from analysis.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sonar-project.properties Updated exclusions to include HTTPStatusCode.swift and EncodableRequest.swift.
Tests/FormbricksSDKTests/Networking/UpdateQueueTests.swift Added comprehensive tests for UpdateQueue behavior.
Tests/FormbricksSDKTests/Networking/ClientAPIEndpointsTests.swift Introduced tests for GetEnvironmentRequest and PostUserRequest initialization.
Tests/FormbricksSDKTests/Networking/APIClientTests.swift Added various tests to validate APIClient’s handling of responses and errors.
Sources/FormbricksSDK/Networking/Base/APIClient.swift Refactored APIClient to accept an injectable URLSession.

Copy link

@mattinannt mattinannt added this pull request to the merge queue May 15, 2025
@mattinannt mattinannt removed this pull request from the merge queue due to a manual request May 15, 2025
@mattinannt mattinannt merged commit f28466f into main May 15, 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