Skip to content

Commit

Permalink
Merge pull request #13 from mrlegowatch/time-zone-test-fixes
Browse files Browse the repository at this point in the history
Fixes tests for any server's time zone, reactivates tests
  • Loading branch information
bobgilmore authored Apr 30, 2021
2 parents 91c8afd + 041535e commit b41720c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Swift

on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v
5 changes: 4 additions & 1 deletion Tests/GarageStorageTests/SwiftCodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,15 @@ class SwiftCodableTests: XCTestCase {

// Set sam's birthdate to 1950/01/01 04:00:00

let timeZone = TimeZone(identifier: "America/New_York")!
var dateComponents = DateComponents()
dateComponents.day = 1
dateComponents.month = 1
dateComponents.year = 1950
dateComponents.timeZone = timeZone

let calendar = Calendar.current
var calendar = Calendar.current
calendar.timeZone = timeZone
sam.birthdate = calendar.date(from: dateComponents)!
XCTAssertEqual(sam.birthdate.timeIntervalSinceReferenceDate, -1609441200.0, "Making assumption about the test")

Expand Down
7 changes: 5 additions & 2 deletions Tests/GarageStorageTests/TestableEdgeCaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,21 @@ class TestableEdgeCaseTests: XCTestCase {

func testDateFormatter() {

let timeZone = TimeZone(identifier: "America/New_York")!
var dateComponents = DateComponents()
dateComponents.day = 1
dateComponents.month = 1
dateComponents.year = 1950
dateComponents.timeZone = timeZone

let calendar = Calendar.current
var calendar = Calendar.current
calendar.timeZone = timeZone
let date = calendar.date(from: dateComponents)!
XCTAssertEqual(date.timeIntervalSinceReferenceDate, -1609441200.0, "Making assumption about the test")

do {
let dateString = date.isoString
XCTAssertEqual(dateString, "1950-01-01T00:00:00-05:00", "isoString failed")
XCTAssertEqual(dateString, "1950-01-01T05:00:00Z", "isoString failed")
}

do {
Expand Down

0 comments on commit b41720c

Please # to comment.