github.com/mponton/terratest@v0.44.0/modules/azure/synapse.go (about)

     1  package azure
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/Azure/azure-sdk-for-go/services/synapse/mgmt/2020-12-01/synapse"
     7  	"github.com/mponton/terratest/modules/testing"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  // GetSynapseWorkspace is a helper function that gets the synapse workspace.
    12  // This function would fail the test if there is an error.
    13  func GetSynapseWorkspace(t testing.TestingT, resGroupName string, workspaceName string, subscriptionID string) *synapse.Workspace {
    14  	Workspace, err := GetSynapseWorkspaceE(t, subscriptionID, resGroupName, workspaceName)
    15  	require.NoError(t, err)
    16  
    17  	return Workspace
    18  }
    19  
    20  // GetSynapseSqlPool is a helper function that gets the synapse workspace.
    21  // This function would fail the test if there is an error.
    22  func GetSynapseSqlPool(t testing.TestingT, resGroupName string, workspaceName string, sqlPoolName string, subscriptionID string) *synapse.SQLPool {
    23  	SQLPool, err := GetSynapseSqlPoolE(t, subscriptionID, resGroupName, workspaceName, sqlPoolName)
    24  	require.NoError(t, err)
    25  
    26  	return SQLPool
    27  }
    28  
    29  // GetSynapseWorkspaceE is a helper function that gets the workspace.
    30  func GetSynapseWorkspaceE(t testing.TestingT, subscriptionID string, resGroupName string, workspaceName string) (*synapse.Workspace, error) {
    31  	// Create a synapse client
    32  	synapseClient, err := CreateSynapseWorkspaceClientE(subscriptionID)
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  
    37  	// Get the corresponding synapse workspace
    38  	synapseWorkspace, err := synapseClient.Get(context.Background(), resGroupName, workspaceName)
    39  	if err != nil {
    40  		return nil, err
    41  	}
    42  
    43  	//Return synapse workspace
    44  	return &synapseWorkspace, nil
    45  }
    46  
    47  // GetSynapseSqlPoolE is a helper function that gets the synapse sql pool.
    48  func GetSynapseSqlPoolE(t testing.TestingT, subscriptionID string, resGroupName string, workspaceName string, sqlPoolName string) (*synapse.SQLPool, error) {
    49  	// Create a synapse client
    50  	synapseSqlPoolClient, err := CreateSynapseSqlPoolClientE(subscriptionID)
    51  	if err != nil {
    52  		return nil, err
    53  	}
    54  
    55  	// Get the corresponding synapse workspace
    56  	synapseSqlPool, err := synapseSqlPoolClient.Get(context.Background(), resGroupName, workspaceName, sqlPoolName)
    57  	if err != nil {
    58  		return nil, err
    59  	}
    60  
    61  	//Return synapse workspace
    62  	return &synapseSqlPool, nil
    63  }