Skip to content

Commit 1a28afc

Browse files
leogdionclaude
andcommitted
Fix BushelKit unit test build issues
- Remove duplicate FormattersTests.swift from BushelUtlitiesTests - Merge formatter tests into BushelFoundationTests where they belong - Update test expectations for ByteCountFormatStyle output format - Fix URL type usage in RestoreImageRecordTests (use URL instead of String) - Fix URL type usage in XcodeVersionRecordTests (use URL instead of String) - Fix URL type usage in SwiftVersionRecordTests (use URL instead of String) All 129 BushelKit tests now pass successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 371e40c commit 1a28afc

File tree

5 files changed

+63
-97
lines changed

5 files changed

+63
-97
lines changed

Packages/BushelKit/Tests/BushelFoundationTests/FormattersTests.swift

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// BushelKit
44
//
55
// Created by Leo Dion.
6-
// Copyright © 2024 BrightDigit.
6+
// Copyright © 2025 BrightDigit.
77
//
88
// Permission is hereby granted, free of charge, to any person
99
// obtaining a copy of this software and associated documentation
@@ -49,4 +49,59 @@ internal final class FormattersTests: XCTestCase {
4949

5050
XCTAssertEqual(actualFormattedNow, expectedFormattedNow)
5151
}
52+
53+
internal func testFormatDate() {
54+
let date = Date(timeIntervalSince1970: 1_700_000_000)
55+
let formatted = date.formatted(Formatters.dateFormat)
56+
57+
// Should return medium date format
58+
XCTAssertFalse(formatted.isEmpty)
59+
XCTAssertTrue(formatted.contains("2023") || formatted.contains("Nov"))
60+
}
61+
62+
internal func testFormatDateTime() {
63+
let date = Date(timeIntervalSince1970: 1_700_000_000)
64+
let formatted = date.formatted(Formatters.dateTimeFormat)
65+
66+
// Should include both date and time
67+
XCTAssertFalse(formatted.isEmpty)
68+
XCTAssertTrue(formatted.contains("2023") || formatted.contains("Nov"))
69+
// Time component varies by timezone
70+
}
71+
72+
internal func testFormatFileSizeGB() {
73+
let bytes = 2_500_000_000 // 2.5 GB
74+
let formatted = bytes.formatted(Formatters.fileSizeFormat)
75+
76+
XCTAssertEqual(formatted, "2.5 GB")
77+
}
78+
79+
internal func testFormatFileSizeMB() {
80+
let bytes = 500_000_000 // 500 MB
81+
let formatted = bytes.formatted(Formatters.fileSizeFormat)
82+
83+
XCTAssertEqual(formatted, "500 MB")
84+
}
85+
86+
internal func testFormatFileSizeSmallMB() {
87+
let bytes = 50_000_000 // 50 MB
88+
let formatted = bytes.formatted(Formatters.fileSizeFormat)
89+
90+
XCTAssertEqual(formatted, "50 MB")
91+
}
92+
93+
internal func testFormatFileSizeLargeGB() {
94+
let bytes = 15_000_000_000 // 15 GB
95+
let formatted = bytes.formatted(Formatters.fileSizeFormat)
96+
97+
XCTAssertEqual(formatted, "15 GB")
98+
}
99+
100+
internal func testFormatFileSizeBoundary() {
101+
// Exactly 1 GB
102+
let bytes = 1_000_000_000
103+
let formatted = bytes.formatted(Formatters.fileSizeFormat)
104+
105+
XCTAssertEqual(formatted, "1 GB")
106+
}
52107
}

Packages/BushelKit/Tests/BushelFoundationTests/RestoreImageRecordTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal final class RestoreImageRecordTests: XCTestCase {
3838
buildNumber: "23C71",
3939
releaseDate: Date(timeIntervalSince1970: 1_700_000_000),
4040
downloadURL:
41-
"https://updates.cdn-apple.com/2023/macos/23C71/UniversalMac_14.2.1_23C71_Restore.ipsw",
41+
URL(string: "https://updates.cdn-apple.com/2023/macos/23C71/UniversalMac_14.2.1_23C71_Restore.ipsw")!,
4242
fileSize: 14_500_000_000,
4343
sha256Hash: "abc123",
4444
sha1Hash: "def456",
@@ -78,7 +78,7 @@ internal final class RestoreImageRecordTests: XCTestCase {
7878
version: "15.0 Beta 3",
7979
buildNumber: "24A5264n",
8080
releaseDate: Date(),
81-
downloadURL: "https://example.com/beta.ipsw",
81+
downloadURL: URL(string: "https://example.com/beta.ipsw")!,
8282
fileSize: 15_000_000_000,
8383
sha256Hash: "beta123",
8484
sha1Hash: "beta456",
@@ -117,7 +117,7 @@ internal final class RestoreImageRecordTests: XCTestCase {
117117
version: "14.0",
118118
buildNumber: "23A344",
119119
releaseDate: Date(),
120-
downloadURL: "https://example.com/restore.ipsw",
120+
downloadURL: URL(string: "https://example.com/restore.ipsw")!,
121121
fileSize: 14_000_000_000,
122122
sha256Hash: "hash256",
123123
sha1Hash: "hash1",

Packages/BushelKit/Tests/BushelFoundationTests/SwiftVersionRecordTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal final class SwiftVersionRecordTests: XCTestCase {
3636
SwiftVersionRecord(
3737
version: "5.9.2",
3838
releaseDate: Date(timeIntervalSince1970: 1_700_000_000),
39-
downloadURL: "https://swift.org/download",
39+
downloadURL: URL(string: "https://swift.org/download")!,
4040
isPrerelease: false,
4141
notes: "Bug fixes and improvements"
4242
)
@@ -46,7 +46,7 @@ internal final class SwiftVersionRecordTests: XCTestCase {
4646
let record = makeSampleRecord()
4747

4848
XCTAssertEqual(record.version, "5.9.2")
49-
XCTAssertEqual(record.downloadURL, "https://swift.org/download")
49+
XCTAssertEqual(record.downloadURL, URL(string: "https://swift.org/download")!)
5050
XCTAssertFalse(record.isPrerelease)
5151
XCTAssertEqual(record.notes, "Bug fixes and improvements")
5252
}

Packages/BushelKit/Tests/BushelFoundationTests/XcodeVersionRecordTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal final class XcodeVersionRecordTests: XCTestCase {
3737
version: "15.1",
3838
buildNumber: "15C65",
3939
releaseDate: Date(timeIntervalSince1970: 1_700_000_000),
40-
downloadURL: "https://developer.apple.com/xcode/download",
40+
downloadURL: URL(string: "https://developer.apple.com/xcode/download")!,
4141
fileSize: 8_000_000_000,
4242
isPrerelease: false,
4343
minimumMacOS: "RestoreImage-23A344",
@@ -52,7 +52,7 @@ internal final class XcodeVersionRecordTests: XCTestCase {
5252

5353
XCTAssertEqual(record.version, "15.1")
5454
XCTAssertEqual(record.buildNumber, "15C65")
55-
XCTAssertEqual(record.downloadURL, "https://developer.apple.com/xcode/download")
55+
XCTAssertEqual(record.downloadURL, URL(string: "https://developer.apple.com/xcode/download")!)
5656
XCTAssertEqual(record.fileSize, 8_000_000_000)
5757
XCTAssertFalse(record.isPrerelease)
5858
XCTAssertEqual(record.minimumMacOS, "RestoreImage-23A344")

Packages/BushelKit/Tests/BushelUtlitiesTests/FormattersTests.swift

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)