Created
November 13, 2018 22:47
-
-
Save ryanpbrewster/494e6be754c94597dd4f916fbaf93394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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