Skip to content

Commit

Permalink
add ClearTests, testCleanRealmAndCaches
Browse files Browse the repository at this point in the history
  • Loading branch information
nixzhu committed Apr 27, 2016
1 parent 3ac02e5 commit 2a327f6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Yep.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
507682F01C9FE8F7006A973E /* SearchContactsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507682EF1C9FE8F7006A973E /* SearchContactsViewController.swift */; };
507682F31C9FE921006A973E /* SearchContacts.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 507682F21C9FE921006A973E /* SearchContacts.storyboard */; };
5076C56A1AC46B9F00B22952 /* FayeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5076C5691AC46B9F00B22952 /* FayeService.swift */; };
507813101CD09FEE00F193AB /* ClearTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5078130F1CD09FEE00F193AB /* ClearTests.swift */; };
507CF1681AFC84A500E261B4 /* CustomNavigationBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507CF1671AFC84A500E261B4 /* CustomNavigationBarViewController.swift */; };
507F65F71B2EBC2700A35FDC /* MediaPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507F65F61B2EBC2700A35FDC /* MediaPreviewView.swift */; };
5080EB1C1B93F43A006F3C2D /* PodsHelpYepViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5080EB1B1B93F43A006F3C2D /* PodsHelpYepViewController.swift */; };
Expand Down Expand Up @@ -651,6 +652,7 @@
507682EF1C9FE8F7006A973E /* SearchContactsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchContactsViewController.swift; path = ViewControllers/SearchContacts/SearchContactsViewController.swift; sourceTree = "<group>"; };
507682F21C9FE921006A973E /* SearchContacts.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = SearchContacts.storyboard; path = ViewControllers/SearchContacts/SearchContacts.storyboard; sourceTree = "<group>"; };
5076C5691AC46B9F00B22952 /* FayeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FayeService.swift; path = Services/FayeService.swift; sourceTree = "<group>"; };
5078130F1CD09FEE00F193AB /* ClearTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClearTests.swift; sourceTree = "<group>"; };
507CF1671AFC84A500E261B4 /* CustomNavigationBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CustomNavigationBarViewController.swift; path = ViewControllers/CustomNavigationBar/CustomNavigationBarViewController.swift; sourceTree = "<group>"; };
507F65F61B2EBC2700A35FDC /* MediaPreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaPreviewView.swift; path = Views/Media/MediaPreviewView.swift; sourceTree = "<group>"; };
5080EB1B1B93F43A006F3C2D /* PodsHelpYepViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PodsHelpYepViewController.swift; path = ViewControllers/PodsHelpYep/PodsHelpYepViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1227,6 +1229,7 @@
children = (
5017FC1C1CD095E100DFCB71 /* YepTests.swift */,
5017FC241CD0960200DFCB71 /* SyncTests.swift */,
5078130F1CD09FEE00F193AB /* ClearTests.swift */,
5017FC1E1CD095E100DFCB71 /* Info.plist */,
);
path = YepTests;
Expand Down Expand Up @@ -3376,6 +3379,7 @@
buildActionMask = 2147483647;
files = (
5017FC251CD0960200DFCB71 /* SyncTests.swift in Sources */,
507813101CD09FEE00F193AB /* ClearTests.swift in Sources */,
5017FC1D1CD095E100DFCB71 /* YepTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -3810,6 +3814,7 @@
5017FC221CD095E100DFCB71 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
50D50AC91CCE01D300FB5753 /* Build configuration list for PBXNativeTarget "YepUITests" */ = {
isa = XCConfigurationList;
Expand Down
54 changes: 54 additions & 0 deletions YepTests/ClearTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// ClearTests.swift
// Yep
//
// Created by NIX on 16/4/27.
// Copyright © 2016年 Catch Inc. All rights reserved.
//

import XCTest
@testable import Yep
import RealmSwift

class ClearTests: XCTestCase {

func testCleanRealmAndCaches() {

cleanRealmAndCaches()

let realm = try! Realm()

do {
let noMessages = realm.objects(Message).isEmpty
XCTAssertTrue(noMessages)
}

do {
let noUsers = realm.objects(User).isEmpty
XCTAssertTrue(noUsers)
}

do {
let noGroups = realm.objects(Group).isEmpty
XCTAssertTrue(noGroups)
}

do {
let noFeeds = realm.objects(Feed).isEmpty
XCTAssertTrue(noFeeds)
}

do {
let path = NSFileManager.yepMessageCachesURL()?.path
let noMessageCacheFiles = try! NSFileManager.defaultManager().contentsOfDirectoryAtPath(path!).isEmpty
XCTAssertTrue(noMessageCacheFiles)
}

do {
let path = NSFileManager.yepAvatarCachesURL()?.path
let noAvatarCacheFiles = try! NSFileManager.defaultManager().contentsOfDirectoryAtPath(path!).isEmpty
XCTAssertTrue(noAvatarCacheFiles)
}
}
}

0 comments on commit 2a327f6

Please sign in to comment.