Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 672940b

Browse files
Fix Examples Unit Tests
1 parent 0834597 commit 672940b

File tree

9 files changed

+65
-31
lines changed

9 files changed

+65
-31
lines changed

Examples/HTTPSRequest/Tests/HTTPSRequestTests/HTTPSRequestTests.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import class Foundation.Bundle
22
import XCTest
33

44
final class HTTPSRequestTests: XCTestCase {
5-
func testExample() throws {
5+
func testMissingLambdaRuntimeApi() throws {
66
// This is an example of a functional test case.
77
// Use XCTAssert and related functions to verify your tests produce the correct
88
// results.
@@ -26,7 +26,9 @@ final class HTTPSRequestTests: XCTestCase {
2626
let data = pipe.fileHandleForReading.readDataToEndOfFile()
2727
let output = String(data: data, encoding: .utf8)
2828

29-
XCTAssertEqual(output, "Hello, world!\n")
29+
let isError = output?.contains("missingEnvironmentVariables(LambdaSwiftSprinter.Context.AWSEnvironmentKey.lambdaRuntimeApi)")
30+
31+
XCTAssertEqual(isError, true)
3032
}
3133

3234
/// Returns path to the built products directory.
@@ -42,6 +44,6 @@ final class HTTPSRequestTests: XCTestCase {
4244
}
4345

4446
static var allTests = [
45-
("testExample", testExample),
47+
("testMissingLambdaRuntimeApi", testMissingLambdaRuntimeApi),
4648
]
4749
}
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
#if !canImport(ObjectiveC)
12
import XCTest
23

3-
#if !canImport(ObjectiveC)
4-
public func allTests() -> [XCTestCaseEntry] {
5-
return [
6-
testCase(HTTPSRequestTests.allTests),
7-
]
8-
}
4+
extension HTTPSRequestTests {
5+
// DO NOT MODIFY: This is autogenerated, use:
6+
// `swift test --generate-linuxmain`
7+
// to regenerate.
8+
static let __allTests__HTTPSRequestTests = [
9+
("testMissingLambdaRuntimeApi", testMissingLambdaRuntimeApi),
10+
]
11+
}
12+
13+
public func __allTests() -> [XCTestCaseEntry] {
14+
return [
15+
testCase(HTTPSRequestTests.__allTests__HTTPSRequestTests),
16+
]
17+
}
918
#endif

Examples/HTTPSRequest/Tests/LinuxMain.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import XCTest
33
import HTTPSRequestTests
44

55
var tests = [XCTestCaseEntry]()
6-
tests += HTTPSRequestTests.allTests()
6+
tests += HTTPSRequestTests.__allTests()
7+
78
XCTMain(tests)

Examples/HelloWorld/Tests/HelloWorldTests/HelloWorldTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import class Foundation.Bundle
22
import XCTest
33

44
final class HelloWorldTests: XCTestCase {
5-
func testExample() throws {
5+
func testMissingLambdaRuntimeApi() throws {
66
// This is an example of a functional test case.
77
// Use XCTAssert and related functions to verify your tests produce the correct
88
// results.
@@ -18,15 +18,15 @@ final class HelloWorldTests: XCTestCase {
1818
process.executableURL = fooBinary
1919

2020
let pipe = Pipe()
21-
process.standardOutput = pipe
21+
process.standardError = pipe
2222

2323
try process.run()
2424
process.waitUntilExit()
2525

2626
let data = pipe.fileHandleForReading.readDataToEndOfFile()
2727
let output = String(data: data, encoding: .utf8)
2828

29-
XCTAssertEqual(output, "Hello, world!\n")
29+
XCTAssertEqual(output, "missingEnvironmentVariables(LambdaSwiftSprinter.Context.AWSEnvironmentKey.lambdaRuntimeApi)\n")
3030
}
3131

3232
/// Returns path to the built products directory.
@@ -42,6 +42,6 @@ final class HelloWorldTests: XCTestCase {
4242
}
4343

4444
static var allTests = [
45-
("testExample", testExample),
45+
("testMissingLambdaRuntimeApi", testMissingLambdaRuntimeApi),
4646
]
4747
}
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
#if !canImport(ObjectiveC)
12
import XCTest
23

3-
#if !canImport(ObjectiveC)
4-
public func allTests() -> [XCTestCaseEntry] {
5-
return [
6-
testCase(HelloWorldTests.allTests),
7-
]
8-
}
4+
extension HelloWorldTests {
5+
// DO NOT MODIFY: This is autogenerated, use:
6+
// `swift test --generate-linuxmain`
7+
// to regenerate.
8+
static let __allTests__HelloWorldTests = [
9+
("testMissingLambdaRuntimeApi", testMissingLambdaRuntimeApi),
10+
]
11+
}
12+
13+
public func __allTests() -> [XCTestCaseEntry] {
14+
return [
15+
testCase(HelloWorldTests.__allTests__HelloWorldTests),
16+
]
17+
}
918
#endif

Examples/HelloWorld/Tests/LinuxMain.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import XCTest
33
import HelloWorldTests
44

55
var tests = [XCTestCaseEntry]()
6-
tests += HelloWorldTests.allTests()
6+
tests += HelloWorldTests.__allTests()
7+
78
XCTMain(tests)

Examples/S3Test/Tests/LinuxMain.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import XCTest
33
import S3TestTests
44

55
var tests = [XCTestCaseEntry]()
6-
tests += S3TestTests.allTests()
6+
tests += S3TestTests.__allTests()
7+
78
XCTMain(tests)

Examples/S3Test/Tests/S3TestTests/S3TestTests.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import class Foundation.Bundle
22
import XCTest
33

44
final class S3TestTests: XCTestCase {
5-
func testExample() throws {
5+
func testMissingLambdaRuntimeApi() throws {
66
// This is an example of a functional test case.
77
// Use XCTAssert and related functions to verify your tests produce the correct
88
// results.
@@ -25,8 +25,10 @@ final class S3TestTests: XCTestCase {
2525

2626
let data = pipe.fileHandleForReading.readDataToEndOfFile()
2727
let output = String(data: data, encoding: .utf8)
28+
29+
let isError = output?.contains("missingEnvironmentVariables(LambdaSwiftSprinter.Context.AWSEnvironmentKey.lambdaRuntimeApi)")
2830

29-
XCTAssertEqual(output, "")
31+
XCTAssertEqual(isError, true)
3032
}
3133

3234
/// Returns path to the built products directory.
@@ -42,6 +44,6 @@ final class S3TestTests: XCTestCase {
4244
}
4345

4446
static var allTests = [
45-
("testExample", testExample),
47+
("testMissingLambdaRuntimeApi", testMissingLambdaRuntimeApi),
4648
]
4749
}
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
#if !canImport(ObjectiveC)
12
import XCTest
23

3-
#if !canImport(ObjectiveC)
4-
public func allTests() -> [XCTestCaseEntry] {
5-
return [
6-
testCase(S3TestTests.allTests),
7-
]
8-
}
4+
extension S3TestTests {
5+
// DO NOT MODIFY: This is autogenerated, use:
6+
// `swift test --generate-linuxmain`
7+
// to regenerate.
8+
static let __allTests__S3TestTests = [
9+
("testMissingLambdaRuntimeApi", testMissingLambdaRuntimeApi),
10+
]
11+
}
12+
13+
public func __allTests() -> [XCTestCaseEntry] {
14+
return [
15+
testCase(S3TestTests.__allTests__S3TestTests),
16+
]
17+
}
918
#endif

0 commit comments

Comments
 (0)