public void BeforeEach()
 {
     _serviceMock      = new Mock <ContainerService>();
     _clustersResource = _serviceMock.Resource(s => s.Projects)
                         .Resource(p => p.Locations)
                         .Resource(l => l.Clusters);
     _objectUnderTest = new GkeDataSource(_serviceMock.Object, DefaultProjectId);
 }
        public async Task TestGetClusterListAsync_PassesCorrectParameter()
        {
            const string expectedProjectId = "expected-project-id";

            _clustersResource.Request(c => c.List(It.IsAny <string>()))
            .ResponseReturns(new ListClustersResponse());
            _objectUnderTest = new GkeDataSource(_serviceMock.Object, expectedProjectId);

            await _objectUnderTest.GetClusterListAsync();

            _clustersResource.Verify(c => c.List($"projects/{expectedProjectId}/locations/-"));
        }
Exemple #3
0
        private async Task <IList <Cluster> > GetAllClustersAsync()
        {
            var dataSource = new GkeDataSource(
                CredentialsStore.Default.CurrentProjectId,
                CredentialsStore.Default.CurrentGoogleCredential,
                GoogleCloudExtensionPackage.ApplicationName);
            var clusters = await dataSource.GetClusterListAsync();

            var result = clusters?.OrderBy(x => x.Name)?.ToList();

            if (result == null || result.Count == 0)
            {
                return(s_placeholderList);
            }
            return(result);
        }