Skip to content

Commit 062225c

Browse files
committed
Add registry-based ApolloSchemaDownloader integration test
1 parent c524531 commit 062225c

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Apollo.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251
E616B6D126C3335600DB049E /* ExecutionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E616B6D026C3335600DB049E /* ExecutionTests.swift */; };
252252
E61DD76526D60C1800C41614 /* SQLiteDotSwiftDatabaseBehaviorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E61DD76426D60C1800C41614 /* SQLiteDotSwiftDatabaseBehaviorTests.swift */; };
253253
E6630B8C26F0639B002D9E41 /* MockNetworkSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D79AB926EC05290094434A /* MockNetworkSession.swift */; };
254+
E6630B8E26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6630B8D26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift */; };
254255
E6D79AB826E9D59C0094434A /* URLDownloaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D79AB626E97D0D0094434A /* URLDownloaderTests.swift */; };
255256
E86D8E05214B32FD0028EFE1 /* JSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E86D8E03214B32DA0028EFE1 /* JSONTests.swift */; };
256257
F16D083C21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F16D083B21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift */; };
@@ -816,6 +817,7 @@
816817
DED45FB3261CDEC60086EF63 /* Apollo-CodegenTestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = "Apollo-CodegenTestPlan.xctestplan"; sourceTree = "<group>"; };
817818
E616B6D026C3335600DB049E /* ExecutionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExecutionTests.swift; sourceTree = "<group>"; };
818819
E61DD76426D60C1800C41614 /* SQLiteDotSwiftDatabaseBehaviorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLiteDotSwiftDatabaseBehaviorTests.swift; sourceTree = "<group>"; };
820+
E6630B8D26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchemaRegistryApolloSchemaDownloaderTests.swift; sourceTree = "<group>"; };
819821
E6D79AB626E97D0D0094434A /* URLDownloaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLDownloaderTests.swift; sourceTree = "<group>"; };
820822
E6D79AB926EC05290094434A /* MockNetworkSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockNetworkSession.swift; sourceTree = "<group>"; };
821823
E86D8E03214B32DA0028EFE1 /* JSONTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONTests.swift; sourceTree = "<group>"; };
@@ -1658,6 +1660,7 @@
16581660
DE6B15B026152BE10068D642 /* Info.plist */,
16591661
DED45F49261CDBFC0086EF63 /* UploadTests.swift */,
16601662
DECD46CF262F64D000924527 /* StarWarsApolloSchemaDownloaderTests.swift */,
1663+
E6630B8D26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift */,
16611664
);
16621665
path = ApolloServerIntegrationTests;
16631666
sourceTree = "<group>";
@@ -2718,6 +2721,7 @@
27182721
DE6B15AF26152BE10068D642 /* DefaultInterceptorProviderIntegrationTests.swift in Sources */,
27192722
DED46000261CE9080086EF63 /* HTTPBinAPI.swift in Sources */,
27202723
DED45F4A261CDBFC0086EF63 /* UploadTests.swift in Sources */,
2724+
E6630B8E26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift in Sources */,
27212725
DED45F17261CDA360086EF63 /* StarWarsWebSocketTests.swift in Sources */,
27222726
DED45D73261675890086EF63 /* StarWarsServerTests.swift in Sources */,
27232727
DED45F30261CDB560086EF63 /* URLSessionClientTests.swift in Sources */,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#if os(macOS)
2+
import XCTest
3+
import ApolloTestSupport
4+
import ApolloCodegenTestSupport
5+
@testable import ApolloCodegenLib
6+
7+
class SchemaRegistryApolloSchemaDownloaderTests: XCTestCase {
8+
func testDownloadingSchema_fromSchemaRegistry_shouldOutputSDL() throws {
9+
let testOutputFolderURL = CodegenTestHelper.outputFolderURL()
10+
XCTAssertFalse(FileManager.default.apollo.fileExists(at: testOutputFolderURL))
11+
12+
guard let apiKey = ProcessInfo.processInfo.environment["REGISTRY_API_KEY"] else {
13+
throw XCTSkip("No API key could be fetched from the environment to test downloading from the schema registry")
14+
}
15+
16+
let settings = ApolloSchemaDownloadConfiguration.DownloadMethod.RegistrySettings(apiKey: apiKey, graphID: "Apollo-Fullstack-8zo5jl")
17+
let configuration = ApolloSchemaDownloadConfiguration(using: .registry(settings),
18+
outputFolderURL: CodegenTestHelper.schemaFolderURL())
19+
20+
try ApolloSchemaDownloader.fetch(with: configuration)
21+
XCTAssertTrue(FileManager.default.apollo.fileExists(at: configuration.outputURL))
22+
23+
// Can it be turned into the expected schema?
24+
let frontend = try ApolloCodegenFrontend()
25+
let source = try frontend.makeSource(from: configuration.outputURL)
26+
let schema = try frontend.loadSchemaFromSDL(source)
27+
let rocketType = try schema.getType(named: "Rocket")
28+
XCTAssertEqual(rocketType?.name, "Rocket")
29+
}
30+
}
31+
#endif

0 commit comments

Comments
 (0)