Skip to content

Instantly share code, notes, and snippets.

@ryanpbrewster
Created November 13, 2018 22:47
Show Gist options
  • 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: "[email protected]"
}
});
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