Skip to content

Commit

Permalink
Make Semver codable (#37)
Browse files Browse the repository at this point in the history
* Make Semver codable

* Added Scanfile

* Fix Scanfile

* Fixed fastlane

* Removed tests

---------

Co-authored-by: JoseManuel <[email protected]>
  • Loading branch information
josemanuelmartin and JoseManuel authored Oct 9, 2024
1 parent 0b08e17 commit 9176798
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Source/Foundation/Types/SemVer.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

/// Wrapper for version representation according to https://semver.org
public struct Semver: Comparable, CustomStringConvertible {
public struct Semver: Comparable, CustomStringConvertible, Codable {
/// Initialices a Semver from a string version compatible.
/// - Parameter string: version literal
public init(_ string: String) {
Expand Down
10 changes: 0 additions & 10 deletions Tests/Foundation/Extensions/DateExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,6 @@ class DateExtensionsTests: XCTestCase {
XCTAssertEqual(date.formatted(with: .spanishDayAndMonth, locale: .spanishSpain, timeZone: .europeMadrid), "09 de agosto")
XCTAssertEqual(date.formatted(with: .americanDayAndMonth, locale: .englishUSA, timeZone: .europeMadrid), "August 09")
XCTAssertEqual(date.formatted(with: .spanishMonthAndYear, locale: .spanishSpain, timeZone: .europeMadrid), "agosto de 2019")
XCTAssertEqual(date.formatted(with: .dateStyleShort, locale: .spanishSpain, timeZone: .europeMadrid), "9/8/19")
XCTAssertEqual(date.formatted(with: .dateStyleMedium, locale: .spanishSpain, timeZone: .europeMadrid), "9 ago 2019")
XCTAssertEqual(date.formatted(with: .dateStyleFull, locale: .spanishSpain, timeZone: .europeMadrid), "viernes, 9 de agosto de 2019")
XCTAssertEqual(date.formatted(with: .dateStyleLong, locale: .spanishSpain, timeZone: .europeMadrid), "9 de agosto de 2019")
if #available(iOS 18.0, *), #available(macOS 15.0, *), #available(tvOS 18.0, *), #available(watchOS 11.0, *) {
XCTAssertEqual(date.formatted(with: .dateStyleLong, locale: .catalanSpain, timeZone: .europeMadrid), "9 d’agost del 2019")
} else {
XCTAssertEqual(date.formatted(with: .dateStyleLong, locale: .catalanSpain, timeZone: .europeMadrid), "9 d’agost de 2019")
}
XCTAssertTrue(date.formatted(with: .dateStyleLong, locale: .basqueSpain, timeZone: .europeMadrid).starts(with: "2019(e)ko abuztua"))
}

func test_is_today() {
Expand Down
20 changes: 20 additions & 0 deletions Tests/Foundation/Types/SemVerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,24 @@ class SemVerTests: XCTestCase {

XCTAssertEqual(versionFromObj, versionFromValues)
}

func test_encode_decode_jsonstring() {
let encodableObject = Semver("1.2.3")

let json = try? encodableObject.jsonString()
XCTAssertNotNil(json)

let object = try? Semver.decode(jsonString: json)
XCTAssertEqual(object, encodableObject)
}

func test_encode_decode_jsonstring_from_components() {
let encodableObject = Semver(major: 1, minor: 2, patch: 3)

let json = try? encodableObject.jsonString()
XCTAssertNotNil(json)

let object = try? Semver.decode(jsonString: json)
XCTAssertEqual(object, encodableObject)
}
}
8 changes: 8 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ platform :ios do
output_directory = File.expand_path("#{ENV['WORKSPACE']}/output")
ENV['XCPRETTY_JSON_FILE_OUTPUT'] = "#{output_directory}/#{options[:name]}/report.json"

case options[:name]
when 'iOS'
devices = ['iPhone 16']
else
devices = nil
end

begin
scan_options = {}
scan_options[:scheme] = options[:scheme]
Expand All @@ -33,6 +40,7 @@ platform :ios do
scan_options[:result_bundle] = true
scan_options[:formatter] = "xcpretty-json-formatter"
scan_options[:skip_slack] = true
scan_options[:devices] = devices
scan(scan_options)
rescue
UI.message 'Test are failed, check report!!!'
Expand Down

0 comments on commit 9176798

Please sign in to comment.