From 216e3699985bead9e6d68b3d11ea0a9b99233772 Mon Sep 17 00:00:00 2001 From: ashlee <100004665+web3ashlee@users.noreply.github.com> Date: Thu, 21 Dec 2023 10:48:19 -0600 Subject: [PATCH] TestSetCollectionExternalUrl (#36) Do we want to test that the url is what we expect? Or is this sufficient Edit: above is included in test now --------- Co-authored-by: ash --- scripts/get_collection_external_url.cdc | 5 +++++ test/FlowtyWrapped_tests.cdc | 10 ++++++++++ transactions/set_collection_external_url.cdc | 15 +++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 scripts/get_collection_external_url.cdc create mode 100644 transactions/set_collection_external_url.cdc diff --git a/scripts/get_collection_external_url.cdc b/scripts/get_collection_external_url.cdc new file mode 100644 index 0000000..defa7c6 --- /dev/null +++ b/scripts/get_collection_external_url.cdc @@ -0,0 +1,5 @@ +import "FlowtyWrapped" + +pub fun main(): String { + return FlowtyWrapped.collectionExternalUrl +} \ No newline at end of file diff --git a/test/FlowtyWrapped_tests.cdc b/test/FlowtyWrapped_tests.cdc index 9d510cc..babc4cd 100644 --- a/test/FlowtyWrapped_tests.cdc +++ b/test/FlowtyWrapped_tests.cdc @@ -46,6 +46,16 @@ pub fun testGetRaffleManager() { scriptExecutor("raffle/borrow_raffle_manager.cdc", [rafflesAcct.address]) } +pub fun testSetCollectionExternalUrl() { + let baseHtmlUrl: String = "https://flowty.io/asset/0x0000000000000007/FlowtyWrappedTEST" + + txExecutor("set_collection_external_url.cdc", [rafflesAcct], [baseHtmlUrl], nil) + + let result = scriptExecutor("get_collection_external_url.cdc", []) + let castedResult = result! as! String + assert(castedResult == baseHtmlUrl, message: "baseHtmlUrl does not match expected") +} + pub fun testMint() { let acct = Test.createAccount() let username: String = "user1" diff --git a/transactions/set_collection_external_url.cdc b/transactions/set_collection_external_url.cdc new file mode 100644 index 0000000..81b0b5b --- /dev/null +++ b/transactions/set_collection_external_url.cdc @@ -0,0 +1,15 @@ +import "FlowtyWrapped" + + +transaction(url: String) { + let admin: &FlowtyWrapped.Admin + + prepare(acct: AuthAccount) { + self.admin = acct.borrow<&FlowtyWrapped.Admin>(from: FlowtyWrapped.AdminStoragePath) + ?? panic("Could not borrow a reference to the NFT minter") + } + + execute { + self.admin.setCollectionExternalUrl(url) + } +} \ No newline at end of file