@@ -12,15 +12,16 @@ import ApolloTestSupport
1212
1313class ApolloSchemaTests : XCTestCase {
1414
15- func testCreatingOptionsWithDefaultParameters ( ) throws {
15+ func testCreatingIntrospectionOptionsWithDefaultParameters ( ) throws {
1616 let sourceRoot = CodegenTestHelper . sourceRootURL ( )
17- let options = ApolloSchemaOptions ( endpointURL: TestURL . starWarsServer. url,
17+
18+ let options = ApolloSchemaOptions ( downloadMethod: . introspection( endpointURL: TestURL . starWarsServer. url) ,
1819 outputFolderURL: sourceRoot)
1920
2021 let expectedOutputURL = sourceRoot. appendingPathComponent ( " schema.json " )
21- XCTAssertEqual ( options. endpointURL, TestURL . starWarsServer. url)
22+
23+ XCTAssertEqual ( options. downloadMethod, . introspection( endpointURL: TestURL . starWarsServer. url) )
2224 XCTAssertEqual ( options. outputURL, expectedOutputURL)
23- XCTAssertNil ( options. apiKey)
2425 XCTAssertTrue ( options. headers. isEmpty)
2526
2627 XCTAssertEqual ( options. arguments, [
@@ -29,31 +30,59 @@ class ApolloSchemaTests: XCTestCase {
2930 " ' \( expectedOutputURL. path) ' "
3031 ] )
3132 }
32-
33- func testCreatingOptionsWithAllParameters( ) throws {
33+
34+ func testCreatingRegistryOptionsWithDefaultParameters( ) throws {
35+ let sourceRoot = CodegenTestHelper . sourceRootURL ( )
36+ let apiKey = " Fake_API_Key "
37+ let graphID = " Fake_Graph_ID "
38+
39+ let settings = ApolloSchemaOptions . DownloadMethod. RegistrySettings ( apiKey: apiKey, graphID: graphID)
40+
41+ let options = ApolloSchemaOptions ( downloadMethod: . registry( settings) ,
42+ outputFolderURL: sourceRoot)
43+
44+ let expectedOutputURL = sourceRoot. appendingPathComponent ( " schema.json " )
45+
46+ XCTAssertEqual ( options. downloadMethod, . registry( settings) )
47+ XCTAssertEqual ( options. outputURL, expectedOutputURL)
48+ XCTAssertTrue ( options. headers. isEmpty)
49+
50+ XCTAssertEqual ( options. arguments, [
51+ " client:download-schema " ,
52+ " --key= \( apiKey) " ,
53+ " --graph= \( graphID) " ,
54+ " ' \( expectedOutputURL. path) ' "
55+ ] )
56+ }
57+
58+ func testCreatingRegistryOptionsWithAllParameters( ) throws {
3459 let sourceRoot = CodegenTestHelper . sourceRootURL ( )
3560 let apiKey = " Fake_API_Key "
61+ let graphID = " Fake_Graph_ID "
62+ let variant = " Fake_Variant "
3663 let firstHeader = " Authorization: Bearer tokenGoesHere "
3764 let secondHeader = " Custom-Header: Custom_Customer "
3865 let headers = [ firstHeader, secondHeader]
3966
67+ let settings = ApolloSchemaOptions . DownloadMethod. RegistrySettings ( apiKey: apiKey,
68+ graphID: graphID, variant: variant)
69+
4070 let options = ApolloSchemaOptions ( schemaFileName: " different_name " ,
4171 schemaFileType: . schemaDefinitionLanguage,
42- apiKey: apiKey,
43- endpointURL: TestURL . starWarsServer. url,
72+ downloadMethod: . registry( settings) ,
4473 headers: headers,
4574 outputFolderURL: sourceRoot)
46- XCTAssertEqual ( options. apiKey, apiKey)
47- XCTAssertEqual ( options. endpointURL, TestURL . starWarsServer. url)
75+ XCTAssertEqual ( options. downloadMethod, . registry( settings) )
4876 XCTAssertEqual ( options. headers, headers)
4977
5078 let expectedOutputURL = sourceRoot. appendingPathComponent ( " different_name.graphql " )
5179 XCTAssertEqual ( options. outputURL, expectedOutputURL)
5280
5381 XCTAssertEqual ( options. arguments, [
5482 " client:download-schema " ,
55- " --endpoint=http://localhost:8080/graphql " ,
5683 " --key= \( apiKey) " ,
84+ " --graph= \( graphID) " ,
85+ " --variant= \( variant) " ,
5786 " ' \( expectedOutputURL. path) ' " ,
5887 " --header=' \( firstHeader) ' " ,
5988 " --header=' \( secondHeader) ' "
@@ -63,7 +92,7 @@ class ApolloSchemaTests: XCTestCase {
6392 func testDownloadingSchemaAsJSON( ) throws {
6493 let testOutputFolderURL = CodegenTestHelper . outputFolderURL ( )
6594
66- let options = ApolloSchemaOptions ( endpointURL: TestURL . starWarsServer. url,
95+ let options = ApolloSchemaOptions ( downloadMethod : . introspection ( endpointURL: TestURL . starWarsServer. url) ,
6796 outputFolderURL: testOutputFolderURL)
6897
6998 // Delete anything existing at the output URL
@@ -97,7 +126,7 @@ class ApolloSchemaTests: XCTestCase {
97126 let testOutputFolderURL = CodegenTestHelper . outputFolderURL ( )
98127
99128 let options = ApolloSchemaOptions ( schemaFileType: . schemaDefinitionLanguage,
100- endpointURL: TestURL . starWarsServer. url,
129+ downloadMethod : . introspection ( endpointURL: TestURL . starWarsServer. url) ,
101130 outputFolderURL: testOutputFolderURL)
102131
103132 // Delete anything existing at the output URL
0 commit comments