This file contains hidden or 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
import Foundation | |
//References: | |
// --: https://www.hackingwithswift.com/articles/153/how-to-test-ios-networking-code-the-easy-way | |
// --: https://nshipster.com/nsurlprotocol/ | |
@objc class URLProtocolMock: URLProtocol { | |
// this dictionary maps URLs to test data | |
static var testURLs = [URL?: Data]() | |
static var response: URLResponse? |
This file contains hidden or 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
func evalValidResponseTest<T:Publisher>(publisher: T?) -> (expectations:[XCTestExpectation], cancellable: AnyCancellable?) { | |
XCTAssertNotNil(publisher) | |
let expectationFinished = expectation(description: "finished") | |
let expectationReceive = expectation(description: "receiveValue") | |
let expectationFailure = expectation(description: "failure") | |
expectationFailure.isInverted = true | |
let cancellable = publisher?.sink (receiveCompletion: { (completion) in | |
switch completion { |
This file contains hidden or 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
func testCreate() { | |
//Setup fixture | |
let usersURL = URL(string: APIDemo.baseURL + "/users") | |
URLProtocolMock.testURLs = [usersURL: Data(Fixtures.createUserResponse.utf8)] | |
//1) When is valid | |
APIDemo.publisher = customPublisher | |
URLProtocolMock.response = mocks.validResponse | |
let publisher = APIDemo.create(user: self.mocks.user) |
This file contains hidden or 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
import XCTest | |
import Foundation | |
import Combine | |
@testable import CombineAPIDemo | |
class Mocks { | |
let user = User(name: "name", | |
email: "email", | |
password: "password", |
This file contains hidden or 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
FROM python:3.9.9-slim-buster | |
RUN apt-get -qq update | |
RUN apt-get install -qqy graphviz graphviz-dev gcc | |
RUN rm -rf /var/lib/apt/lists/* | |
RUN pip install --upgrade pip | |
RUN pip install emerge-viz |
This file contains hidden or 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
MOUNT_ROOT=$(shell pwd) | |
DOCKER_TAG=emerge:1.0.0 | |
docker_build: | |
docker build --tag $(DOCKER_TAG) . | |
docker_bash: | |
docker run \ | |
-it \ | |
--rm \ |
OlderNewer