...

Source file src/edge-infra.dev/pkg/lib/gcp/iam/service_account_test.go

Documentation: edge-infra.dev/pkg/lib/gcp/iam

     1  package iam
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"google.golang.org/api/iam/v1"
     8  )
     9  
    10  const (
    11  	displayName = "test-sa"
    12  	description = "Test Service Account"
    13  	accountID   = "test-account-id"
    14  )
    15  
    16  func TestNewServiceAccount(t *testing.T) {
    17  	expectedSa := &iam.ServiceAccount{
    18  		DisplayName: displayName,
    19  		Description: description,
    20  	}
    21  	actualSa := NewServiceAccount(displayName, description)
    22  	assert.Equal(t, expectedSa, actualSa)
    23  }
    24  
    25  func TestNewServiceAccountRequest(t *testing.T) {
    26  	sa := NewServiceAccount(displayName, description)
    27  	expectedSARequest := &iam.CreateServiceAccountRequest{
    28  		AccountId:      accountID,
    29  		ServiceAccount: sa,
    30  	}
    31  	actualSARequest := NewServiceAccountRequest(accountID, sa)
    32  	assert.Equal(t, expectedSARequest, actualSARequest)
    33  }
    34  
    35  func TestNewServiceAccountKey(t *testing.T) {
    36  	expectedSAKey := &iam.CreateServiceAccountKeyRequest{}
    37  	actualSAKey := NewServiceAccountKeyRequest()
    38  	assert.Equal(t, expectedSAKey, actualSAKey)
    39  }
    40  

View as plain text