Skip to content

Instantly share code, notes, and snippets.

@ryanpbrewster
Created November 13, 2018 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanpbrewster/494e6be754c94597dd4f916fbaf93394 to your computer and use it in GitHub Desktop.
Save ryanpbrewster/494e6be754c94597dd4f916fbaf93394 to your computer and use it in GitHub Desktop.
const firebase = require("@firebase/testing");
async function main() {
const projectId = "my-test-project";
await firebase.loadFirestoreRules({
projectId,
rules: `
service cloud.firestore {
match /databases/{database}/documents {
match /users/{company} {
allow create;
allow update: if request.auth.uid != null;
}
}
}
`
});
const app = firebase.initializeTestApp({
projectId,
auth: {
uid: "ryan",
email: "ryan@example.com"
}
});
await app.firestore().collection("users").doc("ryan").set({
username: "ryan",
join_date: "2018-11-13"
});
await app.delete();
console.log("done!");
}
main().catch(err => {
console.log("ERROR: ", err);
firebase.apps().forEach(app => app.delete());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment