Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
0b4ffdb4
Commit
0b4ffdb4
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add error property to Progress model
parent
4a04d14d
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/Models/Progress.swift
+5
-5
5 additions, 5 deletions
Sources/ElixxirDAppsSDK/Models/Progress.swift
Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift
+26
-1
26 additions, 1 deletion
Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift
with
31 additions
and
6 deletions
Sources/ElixxirDAppsSDK/Models/Progress.swift
+
5
−
5
View file @
0b4ffdb4
...
...
@@ -4,18 +4,19 @@ public struct Progress: Equatable {
public
init
(
completed
:
Bool
,
transmitted
:
Int
,
total
:
Int
total
:
Int
,
error
:
String
?
)
{
self
.
completed
=
completed
self
.
transmitted
=
transmitted
self
.
total
=
total
self
.
error
=
error
}
public
var
completed
:
Bool
public
var
transmitted
:
Int
public
var
total
:
Int
// TODO: add error
// public var error: ???
public
var
error
:
String
?
}
extension
Progress
:
Codable
{
...
...
@@ -23,8 +24,7 @@ extension Progress: Codable {
case
completed
=
"Completed"
case
transmitted
=
"Transmitted"
case
total
=
"Total"
// TODO: add error
// case error = "Err"
case
error
=
"Err"
}
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
...
...
This diff is collapsed.
Click to expand it.
Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift
+
26
−
1
View file @
0b4ffdb4
...
...
@@ -21,7 +21,8 @@ final class ProgressTests: XCTestCase {
XCTAssertNoDifference
(
progress
,
Progress
(
completed
:
completed
,
transmitted
:
transmitted
,
total
:
total
total
:
total
,
error
:
nil
))
let
encodedProgress
=
try
progress
.
encode
()
...
...
@@ -29,4 +30,28 @@ final class ProgressTests: XCTestCase {
XCTAssertNoDifference
(
decodedProgress
,
progress
)
}
func
testDecodingProgressWithError
()
throws
{
let
completed
=
false
let
transmitted
:
Int
=
128
let
total
:
Int
=
2048
let
error
=
"something went wrong"
let
jsonString
=
"""
{
"
Completed
":
\(
completed
)
,
"
Transmitted
":
\(
transmitted
)
,
"
Total
":
\(
total
)
,
"
Err
": "
\(
error
)
"
}
"""
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
progress
=
try
Progress
.
decode
(
jsonData
)
XCTAssertNoDifference
(
progress
,
Progress
(
completed
:
completed
,
transmitted
:
transmitted
,
total
:
total
,
error
:
error
))
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment