Skip to content
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

added an empty test #2

Merged
merged 7 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ jobs:
-Dsonar.projectName=FlickrFinder
-Dsonar.organization=jeroenbakker-wbd
-Dsonar.projectKey=JeroenBakker-wbd_FlickrFinder
-Dsonar.sources=Data/,Domain/,Presentation/,FlickrFinder/
-Dsonar.tests=DataTests/
-Dsonar.sources=.
-Dsonar.tests=.
-Dsonar.test.inclusions=**/Tests/**/*
-Dsoner.exclusions=**/Tests/**/*
-Dsonar.swift.project=FlickrFinder.xcodeproj
-Dsonar.swift.scheme=FlickrFinder
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.token=$SONAR_TOKEN
-Dsonar.coverageReportPaths=coverage.xml
-Dsonar.coverage.exclusions=DataTests/
-Dsonar.coverage.exclusions=**/Tests/**/*
-Dsonar.c.file.suffixes=-
-Dsonar.cpp.file.suffixes=-
-Dsonar.objc.file.suffixes=-
9 changes: 9 additions & 0 deletions Data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
38 changes: 38 additions & 0 deletions Data/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Data",
platforms: [
.iOS(.v16),
.tvOS(.v16),
.watchOS(.v9),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Data",
targets: ["Data"]),
],
dependencies: [
.package(path: "../Domain"),
.package(url: "https://github.com/hmlongco/Factory", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Data",
dependencies: [
.product(name: "Domain", package: "Domain"),
]),
.testTarget(
name: "DataTests",
dependencies: [
"Data",
.product(name: "Factory", package: "Factory")
]),
]
)
3 changes: 3 additions & 0 deletions Data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DataPackage

A description of this package.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Domain
import Factory
import Foundation

// MARK: - Singletons
extension Container: AutoRegistering {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Domain
import Factory
import Foundation

struct APIService: APIWorker {

Expand Down Expand Up @@ -43,4 +44,8 @@ struct APIService: APIWorker {
throw NetworkError.statusCode(httpUrlResponse.statusCode)
}
}

func anEmptyTestWhichShouldBeReportedAsACodeSmell() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum FlickrSearchPhotoError: Error {
enum FlickrSearchPhotoError: Error, Equatable {
case api(FlickrAPIError)
case tooManyTags
case unknownUser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Domain
import Factory
import Foundation

struct SearchPhotosService: SearchPhotosWorker {

Expand Down
18 changes: 0 additions & 18 deletions Data/Supporting Files/Data.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Created by Jeroen Bakker on 28/08/2023.
// Copyright (c) 2023 Bleacher Report. All rights reserved.
//

import XCTest
@testable import Data

final class FlickrSearchPhotoErrorTests: XCTestCase {

func test_init_onUnsupportedInput_shouldReturnAPIEnum() throws {
// given
let input = 0

// when
let result = FlickrSearchPhotoError(rawValue: input)

// then
if case .api(let flickrAPIError) = result {
XCTAssertEqual(.unknown, flickrAPIError)
} else {
XCTFail()
}
}

func test_Init_onSupportedInputs_shouldReturnEnum() throws {
// given
let inputs = [1, 2, 3, 4, 5]
let expectedResults: [FlickrSearchPhotoError] = [
.tooManyTags,
.unknownUser,
.parameterlessSearchesDisabled,
.noPermission,
.userDeleted
]

for (index, input) in inputs.enumerated() {
// when
let result = FlickrSearchPhotoError(rawValue: input)
// then
XCTAssertEqual(expectedResults[index], result)
}
}
}
9 changes: 9 additions & 0 deletions Domain/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
35 changes: 35 additions & 0 deletions Domain/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Domain",
platforms: [
.iOS(.v16),
.tvOS(.v16),
.watchOS(.v9),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Domain",
targets: ["Domain"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/hmlongco/Factory", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Domain",
dependencies: [
.product(name: "Factory", package: "Factory")
]),
.testTarget(
name: "DomainTests",
dependencies: ["Domain"]),
]
)
3 changes: 3 additions & 0 deletions Domain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DomainPackage

A description of this package.
18 changes: 0 additions & 18 deletions Domain/Supporting Files/Domain.h

This file was deleted.

11 changes: 11 additions & 0 deletions Domain/Tests/DomainTests/DomainPackageTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import XCTest
@testable import Domain

final class DomainPackageTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
// XCTAssertEqual(Domain().text, "Hello, World!")
}
}
Loading
Loading