Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion cmake/firebase_unity_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set(FIREBASE_UNITY_JAR_RESOLVER_VERSION "1.2.171"
)

# https://github.com/firebase/firebase-cpp-sdk
set(FIREBASE_CPP_SDK_PRESET_VERSION "origin/unity-v9.0.0"
set(FIREBASE_CPP_SDK_PRESET_VERSION "a192efbda2c22d5c336db00999ac919eb22e5157"
CACHE STRING
"Version tag of Firebase CPP SDK to download (if no local or not passed in) and use (no trailing .0)"
)
2 changes: 2 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ Release Notes
### Upcoming
- Changes
- General: Added a missing namespace to the Google.MiniJson.dll.
- Functions: Add a new method `GetHttpsCallableFromURL`, to create callables
with URLs other than cloudfunctions.net.

### 9.0.0
- Changes
Expand Down
20 changes: 20 additions & 0 deletions functions/src/FirebaseFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ public HttpsCallableReference GetHttpsCallable(string name) {
return new HttpsCallableReference(this, functionsInternal.GetHttpsCallable(name));
}

/// <summary>
/// Creates a
/// <see cref="HttpsCallableReference" />
/// given a URL.
/// </summary>
public HttpsCallableReference GetHttpsCallableFromURL(string url) {
ThrowIfNull();
return new HttpsCallableReference(this, functionsInternal.GetHttpsCallableFromURL(url));
}

/// <summary>
/// Creates a
/// <see cref="HttpsCallableReference" />
/// given a URL.
/// </summary>
public HttpsCallableReference GetHttpsCallableFromURL(Uri url) {
ThrowIfNull();
return GetHttpsCallableFromURL(url.ToString());
}

/// <summary>
/// Sets an origin of a Cloud Functions Emulator instance to use.
/// </summary>
Expand Down
25 changes: 24 additions & 1 deletion functions/testapp/Assets/Firebase/Sample/Functions/TestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ public TestCase(string name, object input, object expectedResult,
ExpectedError = expectedError;
}

// Returns the CallableReference to be used by the test. Overridable to allow
// different ways to generate the CallableReference.
public virtual HttpsCallableReference GetReference(FirebaseFunctions functions) {
return functions.GetHttpsCallable(Name);
}

// Runs the given test and returns whether it passed.
public Task RunAsync(FirebaseFunctions functions,
Utils.Reporter reporter) {
var func = functions.GetHttpsCallable(Name);
var func = GetReference(functions);
return func.CallAsync(Input).ContinueWithOnMainThread((task) => {
if (ExpectedError == FunctionsErrorCode.None) {
// We expected no error.
Expand Down Expand Up @@ -82,4 +88,21 @@ public Task RunAsync(FirebaseFunctions functions,
});
}
}

// TestCase that uses a URL to call the function directly.
public class TestCaseWithURL : TestCase {
// The URL of the function to call
System.Uri URL { get; set; }

public TestCaseWithURL(string name, System.Uri url, object input, object expectedResult,
FunctionsErrorCode expectedError = FunctionsErrorCode.None)
: base(name, input, expectedResult, expectedError) {
URL = url;
}

// Generate the CallableReference using the URL
public override HttpsCallableReference GetReference(FirebaseFunctions functions) {
return functions.GetHttpsCallableFromURL(URL);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public static IEnumerable<TestCase> AllTests() {
FunctionsErrorCode.Internal);
yield return new TestCase("explicitErrorTest", null, null,
FunctionsErrorCode.OutOfRange);

// Test calling via Url
string projectId = FirebaseApp.DefaultInstance.Options.ProjectId;
yield return new TestCaseWithURL("scalarTest via Url",
new System.Uri("https://us-central1-" + projectId + ".cloudfunctions.net/scalarTest"),
17, 76L);
}

protected override void Start() {
Expand Down