Skip to content

Commit

Permalink
test: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
idilhaq committed Dec 2, 2024
1 parent 78ee4c8 commit b18752e
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions api/handler/v1beta1/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ func (s *GrpcHandlersSuite) TestListProvider() {
},
},
},
Policies: []*domain.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
CreatedAt: timeNow,
UpdatedAt: timeNow,
Expand Down Expand Up @@ -82,6 +88,12 @@ func (s *GrpcHandlersSuite) TestListProvider() {
},
},
},
Policies: []*guardianv1beta1.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
CreatedAt: timestamppb.New(timeNow),
UpdatedAt: timestamppb.New(timeNow),
Expand Down Expand Up @@ -172,6 +184,12 @@ func (s *GrpcHandlersSuite) TestGetProvider() {
},
},
},
Policies: []*domain.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
CreatedAt: timeNow,
UpdatedAt: timeNow,
Expand Down Expand Up @@ -200,6 +218,12 @@ func (s *GrpcHandlersSuite) TestGetProvider() {
},
},
},
Policies: []*guardianv1beta1.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
CreatedAt: timestamppb.New(timeNow),
UpdatedAt: timestamppb.New(timeNow),
Expand Down Expand Up @@ -352,6 +376,12 @@ func (s *GrpcHandlersSuite) TestCreateProvider() {
Description: "Please enter your username",
},
},
Policies: []*domain.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
}
expectedResponse := &guardianv1beta1.CreateProviderResponse{
Expand Down Expand Up @@ -390,6 +420,12 @@ func (s *GrpcHandlersSuite) TestCreateProvider() {
Description: "Please enter your username",
},
},
Policies: []*guardianv1beta1.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
CreatedAt: timestamppb.New(timeNow),
UpdatedAt: timestamppb.New(timeNow),
Expand Down Expand Up @@ -434,6 +470,12 @@ func (s *GrpcHandlersSuite) TestCreateProvider() {
Description: "Please enter your username",
},
},
Policies: []*guardianv1beta1.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
}
res, err := s.grpcServer.CreateProvider(context.Background(), req)
Expand Down Expand Up @@ -508,6 +550,12 @@ func (s *GrpcHandlersSuite) TestUpdatedProvider() {
},
},
},
Policies: []*domain.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
}
expectedResponse := &guardianv1beta1.UpdateProviderResponse{
Expand All @@ -534,6 +582,12 @@ func (s *GrpcHandlersSuite) TestUpdatedProvider() {
},
},
},
Policies: []*guardianv1beta1.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
CreatedAt: timestamppb.New(timeNow),
UpdatedAt: timestamppb.New(timeNow),
Expand Down Expand Up @@ -566,6 +620,12 @@ func (s *GrpcHandlersSuite) TestUpdatedProvider() {
},
},
},
Policies: []*guardianv1beta1.ProviderPolicy{
{
When: "test-when",
Policy: "test-policy",
},
},
},
}
res, err := s.grpcServer.UpdateProvider(context.Background(), req)
Expand Down

0 comments on commit b18752e

Please sign in to comment.