added project deploy tests
@@ -22,6 +22,8 @@ import (
"strings"
"testing"
+ "github.com/onflow/flow-cli/pkg/flowkit/contracts"
+
"github.com/onflow/cadence"
"github.com/stretchr/testify/mock"
@@ -93,10 +95,8 @@ func TestProject(t *testing.T) {
}
-func TestProject_Integration(t *testing.T) {
-
- t.Run("Deploy Project", func(t *testing.T) {
- state, s := setupIntegration()
+// used for integration tests
+func simpleDeploy(state *flowkit.State, s *Services, update bool) ([]*contracts.Contract, error) {
srvAcc, _ := state.EmulatorServiceAccount()
c := config.Contract{
@@ -122,7 +122,14 @@ func TestProject_Integration(t *testing.T) {
}
state.Deployments().AddOrUpdate(d)
- contracts, err := s.Project.Deploy(n.Name, false)
+ return s.Project.Deploy(n.Name, update)
+}
+
+func TestProject_Integration(t *testing.T) {
+
+ t.Run("Deploy Project", func(t *testing.T) {
+ state, s := setupIntegration()
+ contracts, err := simpleDeploy(state, s, false)
assert.NoError(t, err)
assert.Len(t, contracts, 1)
assert.Equal(t, contracts[0].Name(), tests.ContractHelloString.Name)
@@ -187,4 +194,24 @@ func TestProject_Integration(t *testing.T) {
assert.Equal(t, contracts[2].Code(), string(tests.ContractC.Source))
})
+ t.Run("Deploy Project Invalid", func(t *testing.T) {
+ // setup
+ state, s := setupIntegration()
+ _, err := simpleDeploy(state, s, false)
+ assert.NoError(t, err)
+
+ _, err = simpleDeploy(state, s, false)
+ assert.Equal(t, err.Error(), "failed to deploy contracts")
+ })
+
+ t.Run("Deploy Project Update", func(t *testing.T) {
+ // setup
+ state, s := setupIntegration()
+ _, err := simpleDeploy(state, s, false)
+ assert.NoError(t, err)
+
+ _, err = simpleDeploy(state, s, true)
+ assert.NoError(t, err)
+ })
+
}
