Skip to content

Commit

Permalink
Merge pull request #11 from niscy-eudiw/feature/test-coverage-xcov-up…
Browse files Browse the repository at this point in the history
…dates

[fix] updated fastfile for coverage
  • Loading branch information
dtsiflit authored Feb 22, 2024
2 parents 9e5494d + b05de7e commit da395b3
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 10 deletions.
32 changes: 32 additions & 0 deletions .swiftpm/OpenID4VCI.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"configurations" : [
{
"id" : "71103F07-F4DF-4158-BF28-C46564F56E9E",
"name" : "Test Scheme Action",
"options" : {

}
}
],
"defaultOptions" : {
"codeCoverage" : {
"targets" : [
{
"containerPath" : "container:",
"identifier" : "OpenID4VCI",
"name" : "OpenID4VCI"
}
]
}
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:",
"identifier" : "OpenID4VCITests",
"name" : "OpenID4VCITests"
}
}
],
"version" : 1
}
97 changes: 97 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/OpenID4VCI.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OpenID4VCI"
BuildableName = "OpenID4VCI"
BlueprintName = "OpenID4VCI"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OpenID4VCITests"
BuildableName = "OpenID4VCITests"
BlueprintName = "OpenID4VCITests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:.swiftpm/OpenID4VCI.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OpenID4VCITests"
BuildableName = "OpenID4VCITests"
BlueprintName = "OpenID4VCITests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OpenID4VCI"
BuildableName = "OpenID4VCI"
BlueprintName = "OpenID4VCI"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
8 changes: 8 additions & 0 deletions Sources/Extensions/String+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ import Foundation

public extension String {

/// Removes spaces, tabs, newlines, and carriage returns from the string.
///
/// - Returns: A new string with spaces, tabs, newlines, and carriage returns removed.
func removeWhitespaceAndNewlines() -> String {
let characterSet = CharacterSet.whitespacesAndNewlines
return self.components(separatedBy: characterSet).joined()
}

/// URL encodes a string using UTF-8 encoding.
///
/// - Returns: The URL-encoded string or nil if encoding fails.
Expand Down
12 changes: 3 additions & 9 deletions Tests/Offer/CredentialOfferRequestTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,17 @@ class CredentialOfferRequestTest: XCTestCase {
}
}
}
"""
""".removeWhitespaceAndNewlines()

let singleLineJSON = value
.replacingOccurrences(of: "\n", with: "")
.replacingOccurrences(of: "\r", with: "")
.replacingOccurrences(of: "\t", with: "")
.replacingOccurrences(of: " ", with: "")

let urlString = "https://example.com/?credential_offer=\(singleLineJSON)"
let urlString = "https://example.com/?credential_offer=\(value)"

// When
let request = try CredentialOfferRequest(urlString: urlString)

// Then
switch request {
case .passByValue(let metaData):
XCTAssertEqual(metaData, singleLineJSON)
XCTAssertEqual(metaData, value)

if let request = CredentialOfferRequestObject(jsonString: value) {
XCTAssert(request.credentials.count == 2)
Expand Down
6 changes: 5 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ platform :ios do
scheme: "OpenID4VCI",
output_directory: "xcov_output",
is_swift_package: true,
minimum_coverage_percentage: 70.0
minimum_coverage_percentage: 30.0
)
if ENV['CI'] != 'true'
sh 'open ../xcov_output/index.html'
Expand All @@ -73,4 +73,8 @@ platform :ios do
)
end

before_all do
FileUtils.remove_dir '../xcov_output', true
end

end

0 comments on commit da395b3

Please sign in to comment.