Skip to content

Commit acdec97

Browse files
committed
fix: fix repohub unit tests
1 parent 4412018 commit acdec97

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

repohub/pkg/tokenstore/tokenstore.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"google.golang.org/grpc"
1111
"google.golang.org/grpc/codes"
12+
"google.golang.org/grpc/credentials/insecure"
1213
"google.golang.org/grpc/status"
1314

1415
"github.com/semaphoreio/semaphore/repohub/pkg/config"
@@ -60,7 +61,7 @@ func (s *TokenStore) FindRepoToken(r *models.Repository) (string, error) {
6061
}
6162

6263
func (s *TokenStore) FindUser(userID string) (*ia_user.DescribeResponse, error) {
63-
conn, err := grpc.Dial(config.UserAPIEndpoint(), grpc.WithInsecure())
64+
conn, err := grpc.NewClient(config.UserAPIEndpoint(), grpc.WithTransportCredentials(insecure.NewCredentials()))
6465
if err != nil {
6566
return nil, err
6667
}
@@ -91,7 +92,7 @@ func (s *TokenStore) findIntegrationToken(projectID string, integrationType stri
9192
return s.fetchRepositoryToken(userID, ia_repository_integrator.IntegrationType(ia_repository_integrator.IntegrationType_value[integrationType]))
9293
}
9394

94-
conn, err := grpc.Dial(config.RepositoryIntegratorAPIEndpoint(), grpc.WithInsecure())
95+
conn, err := grpc.NewClient(config.RepositoryIntegratorAPIEndpoint(), grpc.WithTransportCredentials(insecure.NewCredentials()))
9596
if err != nil {
9697
return "", err
9798
}
@@ -117,7 +118,7 @@ func (s *TokenStore) findIntegrationToken(projectID string, integrationType stri
117118
}
118119

119120
func (s *TokenStore) fetchRepositoryToken(userID string, integrationType ia_repository_integrator.IntegrationType) (string, error) {
120-
conn, err := grpc.Dial(config.UserAPIEndpoint(), grpc.WithInsecure())
121+
conn, err := grpc.NewClient(config.UserAPIEndpoint(), grpc.WithTransportCredentials(insecure.NewCredentials()))
121122
if err != nil {
122123
return "", err
123124
}
@@ -138,7 +139,7 @@ func (s *TokenStore) fetchRepositoryToken(userID string, integrationType ia_repo
138139
}
139140

140141
func (s *TokenStore) findProject(projectID string) (*ia_projecthub.Project, error) {
141-
conn, err := grpc.Dial(config.ProjectAPIEndpoint(), grpc.WithInsecure())
142+
conn, err := grpc.NewClient(config.ProjectAPIEndpoint(), grpc.WithTransportCredentials(insecure.NewCredentials()))
142143
if err != nil {
143144
return nil, err
144145
}

repohub/test/hub/main_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
support "github.com/semaphoreio/semaphore/repohub/test/support"
1111

1212
"google.golang.org/grpc"
13+
"google.golang.org/grpc/credentials/insecure"
1314
)
1415

1516
var testConn *grpc.ClientConn = nil
@@ -26,7 +27,7 @@ func TestMain(m *testing.M) {
2627
// Give some time for the server to start
2728
time.Sleep(5 * time.Second)
2829

29-
conn, err := grpc.Dial("0.0.0.0:4000", grpc.WithInsecure())
30+
conn, err := grpc.NewClient("0.0.0.0:4000", grpc.WithTransportCredentials(insecure.NewCredentials()))
3031
if err != nil {
3132
log.Fatalf("error opening connection to local GPRC server: %v", err)
3233
}

0 commit comments

Comments
 (0)