-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Home 테스트 코드 작성 #202
Merged
Merged
test: Home 테스트 코드 작성 #202
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0198d03
:white_check_mark: HomeInteractorTests 구현
loinsir 8e20f42
:white_check_mark: HomeWorkerTests 작성
loinsir 8626ed7
:white_check_mark: HomePresenterTests 작성
loinsir f0528b4
:white_check_mark: HomeViewControllerTests 작성
loinsir 3805161
:white_check_mark: HomeViewControllerTest 수정
loinsir 5d82694
:white_check_mark: 누락 테스트 케이스 추가
loinsir 3338c69
:bug: 바뀐 서버 데이터 스키마로 변경 적용
loinsir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"customCode": "SUCCESS", | ||
"message": "요청이 성공적으로 처리되었습니다.", | ||
"statusCode": 200, | ||
"data": [ | ||
{ | ||
"member" : { | ||
"id" : 1, | ||
"username" : "loinsir", | ||
"introduce" : "Hi, my name is hwani", | ||
"profile_image_url" : "https://i.namu.wiki/i/HPFgEkrlX8wtU-agoxsqlzllzfJrcFkDSJYFQxdBHUNyjyZtUpS9zy-7-6lfz4ngzB-1wbLRyhIP4TmnwPwKJ0mUec5403r5TJnI3NZpsYJL6GEVQTmR52YoFGLMbaIe4aGSzh4B4InI9r2g0VV74g.svg" | ||
}, | ||
"board" : { | ||
"id" : 1, | ||
"url" : "https://assets.afcdn.com/video49/20210722/v_645516.m3u8", | ||
"video_thumbnail" : "https://think-note.com/wp-content/uploads/2023/07/eta_3.jpg", | ||
"longitude" : "37.0532156213", | ||
"latitude" : "127.060123123", | ||
"title" : "최강 아이돌", | ||
"content" : "게시글 설명" | ||
}, | ||
"tag" : ["나도몰라요", "너도몰라요"] | ||
}, | ||
{ | ||
"member" : { | ||
"id" : 2, | ||
"username" : "chopmozzi", | ||
"introduce" : "Hi, my name is hwani", | ||
"profile_image_url" : "https://m.segye.com/content/image/2023/03/15/20230315514234.jpg" | ||
}, | ||
"board" : { | ||
"id" : 2, | ||
"url" : "https://qc66zhsq1708.edge.naverncp.com/hls/fMG98EEU8c1UirV-awtm4qKJyhaHRcnDymRFlPLZbTs_/layover-station/IMG_0136_AVC_,HD,SD,_1Pass_30fps.mp4.smil/master.m3u8", | ||
"video_thumbnail" : "video_thumbnail_link", | ||
"longitude" : "37.0532156213", | ||
"latitude" : "127.060123123", | ||
"title" : "프로듀스 101", | ||
"content" : "게시글 설명" | ||
}, | ||
"tag" : ["해시태그", "해시태그2"] | ||
}, | ||
{ | ||
"member" : { | ||
"id" : 3, | ||
"username" : "anyukyung", | ||
"introduce" : "Hi, my name is hwani", | ||
"profile_image_url" : "https://images.khan.co.kr/article/2021/11/15/l_2021111502000877900178361.jpg" | ||
}, | ||
"board" : { | ||
"id" : 3, | ||
"url" : "https://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8", | ||
"video_thumbnail" : "https://cdnimg.melon.co.kr/resource/image/cds/musicstory/imgUrl20210831030133473.jpg/melon/quality/90/optimize", | ||
"longitude" : "37.0532156213", | ||
"latitude" : "127.060123123", | ||
"title" : "프로미스 나인", | ||
"content" : "게시글 설명" | ||
}, | ||
"tag" : ["해시태그1", "해시태그2"] | ||
}, | ||
{ | ||
"member" : { | ||
"id" : 4, | ||
"username" : "layover", | ||
"introduce" : "Hi, my name is hwani", | ||
"profile_image_url" : "profile_image_link" | ||
}, | ||
"board" : { | ||
"id" : 4, | ||
"url" : "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8", | ||
"video_thumbnail" : "https://res.heraldm.com/content/image/2023/04/16/20230416000040_0.jpg", | ||
"longitude" : "37.0532156213", | ||
"latitude" : "127.060123123", | ||
"title" : "아이즈원", | ||
"content" : "게시글 설명2" | ||
}, | ||
"tag" : ["해시태그1", "해시태그6"] | ||
} | ||
] | ||
} |
68 changes: 68 additions & 0 deletions
68
iOS/Layover/LayoverTests/Mocks/Workers/MockHomeWorker.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// MockHomeWorker.swift | ||
// LayoverTests | ||
// | ||
// Created by 김인환 on 12/4/23. | ||
// Copyright © 2023 CodeBomber. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import OSLog | ||
|
||
@testable import Layover | ||
|
||
final class MockHomeWorker: HomeWorkerProtocol { | ||
|
||
// MARK: - Properties | ||
|
||
private let provider: ProviderType = Provider(session: .initMockSession(), | ||
authManager: StubAuthManager()) | ||
|
||
// MARK: - Methods | ||
|
||
func fetchPosts() async -> [Post]? { | ||
guard let fileLocation = Bundle.main.url(forResource: "PostList", | ||
withExtension: "json") else { return nil } | ||
|
||
do { | ||
let mockData = try Data(contentsOf: fileLocation) | ||
MockURLProtocol.requestHandler = { request in | ||
let response = HTTPURLResponse(url: request.url!, | ||
statusCode: 200, | ||
httpVersion: nil, | ||
headerFields: nil) | ||
return (response, mockData, nil) | ||
} | ||
let endPoint: EndPoint = EndPoint<Response<[PostDTO]>>(path: "/board/home", | ||
method: .GET) | ||
let response = try await provider.request(with: endPoint) | ||
guard let data = response.data else { return nil } | ||
return data.map { $0.toDomain() } | ||
} catch { | ||
os_log(.error, log: .data, "%@", error.localizedDescription) | ||
return nil | ||
} | ||
} | ||
|
||
func fetchImageData(of url: URL) async -> Data? { | ||
do { | ||
guard let imageURL = Bundle.main.url(forResource: "sample", withExtension: "jpeg") else { | ||
return nil | ||
} | ||
let mockData = try? Data(contentsOf: imageURL) | ||
MockURLProtocol.requestHandler = { request in | ||
let response = HTTPURLResponse(url: request.url!, | ||
statusCode: 200, | ||
httpVersion: nil, | ||
headerFields: nil) | ||
return (response, mockData, nil) | ||
} | ||
|
||
let data = try await provider.request(url: url) | ||
return data | ||
} catch { | ||
os_log(.error, log: .data, "%@", error.localizedDescription) | ||
return nil | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍