Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthpun committed Feb 17, 2024
1 parent 7d04d57 commit becb0d2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/migrate/get_staged_code_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/onflow/cadence"
"github.com/onflow/contract-updater/lib/go/templates"
"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/config"
"github.com/onflow/flowkit/v2/tests"
Expand Down Expand Up @@ -70,6 +71,8 @@ func Test_GetStagedCode(t *testing.T) {

actualContractAddressArg, actualContractNameArg := script.Args[0], script.Args[1]

assert.Equal(t, templates.GenerateGetStagedContractCodeScript(MigrationContractStagingAddress("testnet")), script.Code)

assert.Equal(t, 2, len(script.Args))

assert.EqualValues(t, testContract.Name, actualContractNameArg)
Expand Down
3 changes: 3 additions & 0 deletions internal/migrate/is_staged_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/onflow/cadence"
"github.com/onflow/contract-updater/lib/go/templates"
"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/config"
"github.com/onflow/flowkit/v2/tests"
Expand Down Expand Up @@ -69,6 +70,8 @@ func Test_IsStaged(t *testing.T) {
srv.ExecuteScript.Run(func(args mock.Arguments) {
script := args.Get(1).(flowkit.Script)

assert.Equal(t, templates.GenerateIsStagedScript(MigrationContractStagingAddress("testnet")), script.Code)

assert.Equal(t, 2, len(script.Args))
actualContractAddressArg, actualContractNameArg := script.Args[0], script.Args[1]

Expand Down
8 changes: 8 additions & 0 deletions internal/migrate/list_staged_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
"testing"

"github.com/onflow/cadence"
"github.com/onflow/contract-updater/lib/go/templates"
"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

Expand All @@ -38,8 +40,14 @@ func Test_ListStagedContracts(t *testing.T) {
account, err := state.EmulatorServiceAccount()
assert.NoError(t, err)

srv.Network.Return(config.Network{
Name: "testnet",
}, nil)

srv.ExecuteScript.Run(func(args mock.Arguments) {
script := args.Get(1).(flowkit.Script)

assert.Equal(t, templates.GenerateGetStagedContractNamesForAddressScript(MigrationContractStagingAddress("testnet")), script.Code)
assert.Equal(t, 1, len(script.Args))

actualContractAddressArg := script.Args[0]
Expand Down
4 changes: 3 additions & 1 deletion internal/migrate/stage_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/onflow/cadence"
"github.com/onflow/contract-updater/lib/go/templates"
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/config"
Expand Down Expand Up @@ -69,9 +70,10 @@ func Test_StageContract(t *testing.T) {
accountRoles := args.Get(1).(transactions.AccountRoles)
script := args.Get(2).(flowkit.Script)

assert.Equal(t, templates.GenerateStageContractScript(MigrationContractStagingAddress("testnet")), script.Code)

assert.Equal(t, 1, len(accountRoles.Signers()))
assert.Equal(t, "emulator-account", accountRoles.Signers()[0].Name)

assert.Equal(t, 2, len(script.Args))

actualContractNameArg, actualContractCodeArg := script.Args[0], script.Args[1]
Expand Down
3 changes: 3 additions & 0 deletions internal/migrate/unstage_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/onflow/cadence"
"github.com/onflow/contract-updater/lib/go/templates"
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/config"
Expand Down Expand Up @@ -69,6 +70,8 @@ func Test_UnstageContract(t *testing.T) {
accountRoles := args.Get(1).(transactions.AccountRoles)
script := args.Get(2).(flowkit.Script)

assert.Equal(t, templates.GenerateUnstageContractScript(MigrationContractStagingAddress("testnet")), script.Code)

assert.Equal(t, 1, len(accountRoles.Signers()))
assert.Equal(t, "emulator-account", accountRoles.Signers()[0].Name)
assert.Equal(t, 1, len(script.Args))
Expand Down

0 comments on commit becb0d2

Please sign in to comment.