Skip to content

Commit

Permalink
get user by id
Browse files Browse the repository at this point in the history
  • Loading branch information
jnetoatbliss committed Feb 8, 2021
1 parent 97c4c62 commit 66726cc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
38 changes: 12 additions & 26 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension Endpoint {
}

static func user(id: String) -> Self {
Endpoint(path: "/users/\(id)")
Endpoint(path: "/c706cbfe-6550-4d3a-9d9b-ae19d1425245/\(id)")
}

static func createUser(user: User) -> Self {
Expand Down
33 changes: 25 additions & 8 deletions Tests/ToolboxAPIClientTests/Tests/app_zeneto_api_moduleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class app_zeneto_api_moduleTests: XCTestCase {
static var allTests = [
("getUsers", testGetUser),
("getUsersWithLimit", testGetUserWithLimit),
("getUsersByID", testGetUserById),
("createUser", testCreateUser)
]

override func setUpWithError() throws {
Expand Down Expand Up @@ -85,6 +87,29 @@ class app_zeneto_api_moduleTests: XCTestCase {
wait(for: [expectation], timeout: timeout)
}

func testGetUserById() throws {
let networkManager = NetworkManager()
let userManager = UserNetworkManager(networkController: networkManager)
var subscriptions = Set<AnyCancellable>()

let id: String = "a94bff9b-d0fc-49ba-9a4f-4f9234d16561"
userManager.getUser(id: id)
.sink(receiveCompletion: { [weak self] completion in
switch completion {
case let .failure(error):
print("Error API: \(error)")
XCTFail()
case .finished:
self?.expectation.fulfill()
break
}
}, receiveValue: { (value: User?) in
XCTAssertNotNil(value)
}).store(in: &subscriptions)

wait(for: [expectation], timeout: timeout)
}

func testCreateUser() throws {
let networkManager = NetworkManager()
let userManager = UserNetworkManager(networkController: networkManager)
Expand All @@ -111,12 +136,4 @@ class app_zeneto_api_moduleTests: XCTestCase {

wait(for: [expectation], timeout: timeout)
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}

0 comments on commit 66726cc

Please sign in to comment.