Skip to content

Commit ff553a9

Browse files
authored
Merge pull request #437 from zapcannon87/master
chore: update gitignore & cli
2 parents 8ed5783 + 4497970 commit ff553a9

File tree

7 files changed

+77
-134
lines changed

7 files changed

+77
-134
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Brew
2+
Brewfile.lock.json
3+
4+
# Gem
5+
Gemfile.lock
6+
17
# macOS
28
*.DS_Store
39

LeanCloudTests/BaseTestCase.swift

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,43 @@ class BaseTestCase: XCTestCase {
2626
let key: String
2727
let serverURL: String
2828
let testableServerURL: String
29+
let masterKey: String
2930
}
3031

3132
static let cnApp = AppInfo(
3233
id: "S5vDI3IeCk1NLLiM1aFg3262-gzGzoHsz",
3334
key: "7g5pPsI55piz2PRLPWK5MPz0",
3435
serverURL: "https://s5vdi3ie.lc-cn-n1-shared.com",
35-
testableServerURL: "https://beta.leancloud.cn")
36+
testableServerURL: "https://beta.leancloud.cn",
37+
masterKey: "Q26gTodbyi1Ki7lM9vtncF6U")
38+
39+
static let tds1App = AppInfo(
40+
id: "7DY3DVgOQogGnYMMUajgvPRq-TjsS5DXC",
41+
key: "RJOLaAvGiF7mQguXp68W9Mv5",
42+
serverURL: "https://7DY3DVgO.cloud.tds1.tapapis.cn",
43+
testableServerURL: "",
44+
masterKey: "3PSWpjByenawCVo0FpnXfNgx")
3645

3746
static let ceApp = AppInfo(
3847
id: "skhiVsqIk7NLVdtHaUiWn0No-9Nh9j0Va",
3948
key: "T3TEAIcL8Ls5XGPsGz41B1bz",
4049
serverURL: "https://skhivsqi.lc-cn-e1-shared.com",
41-
testableServerURL: "https://beta-tab.leancloud.cn")
50+
testableServerURL: "https://beta-tab.leancloud.cn",
51+
masterKey: "FTPdEcG7vLKxNqKxYhTFdK4g")
4252

4353
static let usApp = AppInfo(
4454
id: "jenSt9nvWtuJtmurdE28eg5M-MdYXbMMI",
4555
key: "8VLPsDlskJi8KsKppED4xKS0",
4656
serverURL: "",
47-
testableServerURL: "https://beta-us.leancloud.cn")
57+
testableServerURL: "https://beta-us.leancloud.cn",
58+
masterKey: "fasiJXz8jvSwn3G2B2QeraRe")
59+
60+
static let appInfoTable = [
61+
cnApp.id : cnApp,
62+
tds1App.id : tds1App,
63+
ceApp.id : ceApp,
64+
usApp.id : usApp,
65+
]
4866

4967
static var config: LCApplication.Configuration {
5068
var config = LCApplication.Configuration()
@@ -58,6 +76,7 @@ class BaseTestCase: XCTestCase {
5876
override class func setUp() {
5977
super.setUp()
6078
let app = BaseTestCase.cnApp
79+
// let app = BaseTestCase.tds1App
6180
// let app = BaseTestCase.ceApp
6281
// let app = BaseTestCase.usApp
6382
TestObject.register()
@@ -70,17 +89,27 @@ class BaseTestCase: XCTestCase {
7089
configuration: BaseTestCase.config)
7190
}
7291

92+
override func setUp() {
93+
super.setUp()
94+
BaseTestCase.cleanPersistentCache()
95+
}
96+
7397
override class func tearDown() {
74-
[LCApplication.default.applicationSupportDirectoryURL,
75-
LCApplication.default.cachesDirectoryURL]
76-
.forEach { (url) in
77-
if FileManager.default.fileExists(atPath: url.path) {
78-
try! FileManager.default.removeItem(at: url)
79-
}
80-
}
98+
cleanPersistentCache()
8199
LCApplication.default.unregister()
82100
super.tearDown()
83101
}
102+
103+
static func cleanPersistentCache() {
104+
[
105+
LCApplication.default.applicationSupportDirectoryURL,
106+
LCApplication.default.cachesDirectoryURL,
107+
].forEach { (url) in
108+
if FileManager.default.fileExists(atPath: url.path) {
109+
try! FileManager.default.removeItem(at: url)
110+
}
111+
}
112+
}
84113
}
85114

86115
extension BaseTestCase {
@@ -167,18 +196,10 @@ extension BaseTestCase {
167196
extension LCApplication {
168197

169198
var masterKey: String {
170-
let key: String
171-
switch self.id {
172-
case BaseTestCase.cnApp.id:
173-
key = "Q26gTodbyi1Ki7lM9vtncF6U"
174-
case BaseTestCase.ceApp.id:
175-
key = "FTPdEcG7vLKxNqKxYhTFdK4g"
176-
case BaseTestCase.usApp.id:
177-
key = "fasiJXz8jvSwn3G2B2QeraRe"
178-
default:
199+
guard let key = BaseTestCase.appInfoTable[self.id]?.masterKey else {
179200
fatalError()
180201
}
181-
return key + ",master"
202+
return "\(key),master"
182203
}
183204

184205
var v2router: AppRouter {
@@ -189,11 +210,11 @@ extension LCApplication {
189210

190211
var applicationSupportDirectoryURL: URL {
191212
return (try!
192-
FileManager.default.url(
193-
for: .applicationSupportDirectory,
194-
in: .userDomainMask,
195-
appropriateFor: nil,
196-
create: false))
213+
FileManager.default.url(
214+
for: .applicationSupportDirectory,
215+
in: .userDomainMask,
216+
appropriateFor: nil,
217+
create: false))
197218
.appendingPathComponent(
198219
LocalStorageContext.domain,
199220
isDirectory: true)
@@ -204,11 +225,11 @@ extension LCApplication {
204225

205226
var cachesDirectoryURL: URL {
206227
return (try!
207-
FileManager.default.url(
208-
for: .cachesDirectory,
209-
in: .userDomainMask,
210-
appropriateFor: nil,
211-
create: false))
228+
FileManager.default.url(
229+
for: .cachesDirectory,
230+
in: .userDomainMask,
231+
appropriateFor: nil,
232+
create: false))
212233
.appendingPathComponent(
213234
LocalStorageContext.domain,
214235
isDirectory: true)

LeanCloudTests/LCFileTestCase.swift

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -78,71 +78,6 @@ class LCFileTestCase: BaseTestCase {
7878
XCTAssertNil(wFile3)
7979
}
8080

81-
func testSaveUS() {
82-
/*
83-
let fileURL = bundleResourceURL(name: "test", ext: "png")
84-
let application = LCRouterTestCase.usApplication
85-
86-
var file1: LCFile! = LCFile(
87-
application: application,
88-
payload: .fileURL(fileURL: fileURL))
89-
XCTAssertTrue(file1.save().isSuccess)
90-
XCTAssertNotNil(file1.mimeType)
91-
XCTAssertNotNil(file1.key)
92-
XCTAssertNotNil(file1.name)
93-
XCTAssertNotNil(file1.metaData?.size as? LCNumber)
94-
XCTAssertNotNil(file1.bucket)
95-
XCTAssertNotNil(file1.provider)
96-
XCTAssertNotNil(file1.url)
97-
XCTAssertNotNil(file1.objectId)
98-
XCTAssertNotNil(file1.createdAt)
99-
XCTAssertNotNil(file1.save().error)
100-
101-
var file2: LCFile! = LCFile(
102-
application: application,
103-
payload: .data(data: try! Data(contentsOf: fileURL)))
104-
file2.name = "image.png"
105-
XCTAssertTrue(file2.save().isSuccess)
106-
XCTAssertNotNil(file2.mimeType)
107-
XCTAssertNotNil(file2.key)
108-
XCTAssertNotNil(file2.name)
109-
XCTAssertNotNil(file2.metaData?.size as? LCNumber)
110-
XCTAssertNotNil(file2.bucket)
111-
XCTAssertNotNil(file2.provider)
112-
XCTAssertNotNil(file2.url)
113-
XCTAssertNotNil(file2.objectId)
114-
XCTAssertNotNil(file2.createdAt)
115-
XCTAssertNotNil(file2.save().error)
116-
117-
var file3: LCFile!
118-
if let file2url = file2.url {
119-
file3 = LCFile(
120-
application: application,
121-
url: file2url)
122-
XCTAssertTrue(file3.save().isSuccess)
123-
XCTAssertNotNil(file3.mimeType)
124-
XCTAssertNotNil(file3.name)
125-
XCTAssertEqual(file3.metaData?.__source as? LCString, LCString("external"))
126-
XCTAssertNotNil(file3.url)
127-
XCTAssertNotNil(file3.objectId)
128-
XCTAssertNotNil(file3.createdAt)
129-
XCTAssertNotNil(file3.save().error)
130-
}
131-
132-
delay()
133-
134-
weak var wFile1 = file1
135-
weak var wFile2 = file2
136-
weak var wFile3 = file3
137-
file1 = nil
138-
file2 = nil
139-
file3 = nil
140-
XCTAssertNil(wFile1)
141-
XCTAssertNil(wFile2)
142-
XCTAssertNil(wFile3)
143-
*/
144-
}
145-
14681
func testSaveAsync() {
14782
let fileURL = bundleResourceURL(name: "test", ext: "png")
14883
var file: LCFile! = LCFile(payload: .fileURL(fileURL: fileURL))
@@ -232,24 +167,4 @@ class LCFileTestCase: BaseTestCase {
232167
object.fileMapField = ["file1": LCFile(url: file.url!)]
233168
XCTAssertTrue(object.save().isSuccess)
234169
}
235-
236-
func testThumbnailURL() {
237-
/*
238-
[bundleResourceURL(name: "test", ext: "jpg"),
239-
bundleResourceURL(name: "test", ext: "png")]
240-
.forEach { (url) in
241-
let file = LCFile(payload: .fileURL(fileURL: url))
242-
let thumbnails: [LCFile.Thumbnail] = [
243-
.scale(0.5),
244-
.size(width: 100, height: 100)]
245-
thumbnails.forEach { (thumbnail) in
246-
XCTAssertNil(file.thumbnailURL(thumbnail))
247-
}
248-
XCTAssertTrue(file.save().isSuccess)
249-
thumbnails.forEach { (thumbnail) in
250-
XCTAssertNotNil(UIImage(data: (try! Data(contentsOf: file.thumbnailURL(thumbnail)!))))
251-
}
252-
}
253-
*/
254-
}
255170
}

LeanCloudTests/LCQueryTestCase.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,22 @@ class LCQueryTestCase: BaseTestCase {
446446
let object = sharedObject
447447
let child = sharedChild
448448
let query = objectQuery()
449-
449+
guard let _ = object.objectId, let _ = child.objectId else {
450+
XCTFail()
451+
return
452+
}
450453
query.whereKey("objectId", .containedIn([object.objectId!, child.objectId!]))
451454
query.whereKey("objectId", .ascending)
452-
453455
let (isSuccess, objects) = execute(query)
454-
455-
XCTAssertTrue(isSuccess && !objects.isEmpty)
456-
457-
let objectId1 = objects[0].objectId!
458-
let objectId2 = objects.last?.objectId!
459-
460-
XCTAssertTrue((objectId1.value as NSString).compare(objectId2!.value) == .orderedAscending)
456+
XCTAssertTrue(isSuccess)
457+
guard objects.count == 2,
458+
let objectId1 = objects.first?.objectId?.value,
459+
let objectId2 = objects.last?.objectId?.value
460+
else {
461+
XCTFail()
462+
return
463+
}
464+
XCTAssertTrue(objectId1.compare(objectId2) == .orderedAscending)
461465
}
462466

463467
func testDescending() {

LeanCloudTests/LCSMSTestCase.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ class LCSMSTestCase: BaseTestCase {
1313

1414
let mobilePhoneNumber = ""
1515

16-
func testRequestVerificationCode() {
16+
// func testRequestVerificationCode() {
1717
// XCTAssertTrue(LCSMSClient.requestVerificationCode(
1818
// mobilePhoneNumber: self.mobilePhoneNumber,
1919
// timeToLive: 1)
2020
// .isSuccess)
21-
}
21+
// }
2222

23-
func testVerifyMobilePhoneNumber() {
23+
// func testVerifyMobilePhoneNumber() {
2424
// XCTAssertTrue(LCSMSClient.verifyMobilePhoneNumber(
2525
// self.mobilePhoneNumber,
2626
// verificationCode: "")
2727
// .isSuccess)
28-
}
28+
// }
2929
}

LeanCloudTests/RTMBaseTestCase.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import XCTest
1010
@testable import LeanCloud
1111

1212
class RTMBaseTestCase: BaseTestCase {
13-
// static let useTestableRTMURL = true
14-
static let useTestableRTMURL = false
15-
static let testableRTMURL = RTMBaseTestCase.useTestableRTMURL
16-
? URL(string: "wss://cn-n1-prod-k8s-cell-12.leancloud.cn")!
17-
: nil
13+
static let testableRTMURL: URL? = nil
14+
// static let testableRTMURL: URL? = URL(string: "wss://cn-n1-prod-k8s-cell-12.leancloud.cn")
1815
}

main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ class JazzyTask: Task {
497497
try generateDocumentation(currentVersion: currentVersion)
498498
try moveGeneratedDocumentationToRepo()
499499
try commitPush()
500-
try OpenTask.url("http://jenkins.avoscloud.com/job/cn-api-doc-prod-ucloud/build")
500+
try OpenTask.url("https://jenkins.leancloud.cn/job/cn-api-doc-prod-ucloud/build")
501501
}
502502
}
503503

0 commit comments

Comments
 (0)