github.com/jfrog/frogbot@v1.1.1-0.20231221090046-821a26f50338/azure_test.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/jfrog/frogbot/utils"
     5  	"github.com/jfrog/froggit-go/vcsclient"
     6  	"github.com/jfrog/froggit-go/vcsutils"
     7  	"github.com/stretchr/testify/assert"
     8  	"testing"
     9  )
    10  
    11  const (
    12  	azureIntegrationTokenEnv = "FROGBOT_TESTS_AZURE_TOKEN"
    13  	azureApiEndpoint         = "https://dev.azure.com/frogbot-test"
    14  	azureGitCloneUrl         = "https://frogbot-test@dev.azure.com/frogbot-test/integration/_git/integration"
    15  )
    16  
    17  func buildAzureReposClient(t *testing.T, azureToken string) vcsclient.VcsClient {
    18  	azureClient, err := vcsclient.NewClientBuilder(vcsutils.AzureRepos).Project(repoName).ApiEndpoint(azureApiEndpoint).Token(azureToken).Build()
    19  	assert.NoError(t, err)
    20  	return azureClient
    21  }
    22  
    23  func buildAzureReposIntegrationTestDetails(t *testing.T) *IntegrationTestDetails {
    24  	integrationRepoToken := getIntegrationToken(t, azureIntegrationTokenEnv)
    25  	testDetails := NewIntegrationTestDetails(integrationRepoToken, string(utils.AzureRepos), azureGitCloneUrl, "frogbot-test")
    26  	testDetails.ApiEndpoint = azureApiEndpoint
    27  	return testDetails
    28  }
    29  
    30  func azureReposTestsInit(t *testing.T) (vcsclient.VcsClient, *IntegrationTestDetails) {
    31  	testDetails := buildAzureReposIntegrationTestDetails(t)
    32  	azureClient := buildAzureReposClient(t, testDetails.GitToken)
    33  	return azureClient, testDetails
    34  }
    35  
    36  func TestAzureRepos_ScanPullRequestIntegration(t *testing.T) {
    37  	azureClient, testDetails := azureReposTestsInit(t)
    38  	runScanPullRequestCmd(t, azureClient, testDetails)
    39  }
    40  
    41  func TestAzureRepos_ScanRepositoryIntegration(t *testing.T) {
    42  	azureClient, testDetails := azureReposTestsInit(t)
    43  	runScanRepositoryCmd(t, azureClient, testDetails)
    44  }