github.com/supabase/cli@v1.168.1/test/branch_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"encoding/json"
     5  	"os"
     6  
     7  	"github.com/docker/docker/api/types"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  // this is the part of Database test suite - DBTestSuite
    12  // test functions
    13  func (suite *DBTestSuite) TestBranchCreate() {
    14  	suite.T().Skip("Local branching is deprecated")
    15  	// create branch
    16  	branch := "test-branch"
    17  	create, args, err := suite.cmd.Traverse([]string{"db", "branch", "create", branch})
    18  	if err != nil {
    19  		suite.Fail("failed to find create command")
    20  	}
    21  	err = create.RunE(create, args)
    22  	if err != nil {
    23  		suite.Fail("failed to create branch", err)
    24  	}
    25  
    26  	// check if branch dir exists
    27  	_, err = os.Stat("supabase/.branches/" + branch)
    28  	require.NoError(suite.T(), err)
    29  
    30  	// check if all exec calls were made to docker api
    31  	ids := suite.constructParams()
    32  	require.ElementsMatch(suite.T(), suite.params, ids)
    33  
    34  	// check commands in exec calls
    35  	require.Equal(suite.T(), 2, len(suite.bodies))
    36  	var execBody types.ExecConfig
    37  	require.NoError(suite.T(), json.Unmarshal([]byte(suite.bodies[0]), &execBody))
    38  	var startBody types.ExecStartCheck
    39  	require.NoError(suite.T(), json.Unmarshal([]byte(suite.bodies[1]), &startBody))
    40  }