Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Testing the timestamp change
Browse files Browse the repository at this point in the history
  • Loading branch information
izaaklauer committed Jun 4, 2021
1 parent 81f0fe1 commit 34e69f2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions internal/core/app_status_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"context"
"google.golang.org/protobuf/types/known/timestamppb"
"testing"

"github.com/golang/protobuf/ptypes"
Expand Down Expand Up @@ -113,22 +114,28 @@ func TestAppDeploymentStatusReport(t *testing.T) {
require.NoError(err)
deploy := resp.Deployment

statusReportTs := timestamppb.Now()
mock.Status.On("StatusFunc").Return(func(context.Context) (*sdk.StatusReport, error) {
return &sdk.StatusReport{}, nil
return &sdk.StatusReport{
TimeGenerated: statusReportTs,
}, nil
})

// Status Report

srResp, err := app.DeploymentStatusReport(context.Background(), deploy)
statusReport := &sdk.StatusReport{}
anypb.UnmarshalTo(srResp.StatusReport, statusReport, proto.UnmarshalOptions{})
require.NoError(err)
require.NotNil(srResp.StatusReport)
require.NotNil(statusReport.Health)

// Verify that we have a Target of the right type with the right id
require.IsType(srResp.TargetId, &pb.StatusReport_DeploymentId{})
require.Equal(srResp.TargetId.(*pb.StatusReport_DeploymentId).DeploymentId, deploy.Id)

// Verify that the status report timestamp made it into the server resp
require.NotNil(srResp.GeneratedTime)
require.True(srResp.GeneratedTime.AsTime().Equal(statusReportTs.AsTime()))
})
}

Expand Down Expand Up @@ -244,8 +251,11 @@ func TestAppReleaseStatusReport(t *testing.T) {
require.NoError(err)
release := releaseResp.Release

statusReportTs := timestamppb.Now()
mock.Status.On("StatusFunc").Return(func(context.Context) (*sdk.StatusReport, error) {
return &sdk.StatusReport{}, nil
return &sdk.StatusReport{
TimeGenerated: statusReportTs,
}, nil
})

// Status Report
Expand All @@ -256,9 +266,13 @@ func TestAppReleaseStatusReport(t *testing.T) {
require.NotNil(srResp.StatusReport)
require.NotNil(statusReport.Health)

// Verify that we have a Target of the right type with the right id
require.IsType(srResp.TargetId, &pb.StatusReport_ReleaseId{})
require.Equal(srResp.TargetId.(*pb.StatusReport_ReleaseId).ReleaseId, release.Id)

// Verify that the status report timestamp made it into the server resp
require.NotNil(srResp.GeneratedTime)
require.True(srResp.GeneratedTime.AsTime().Equal(statusReportTs.AsTime()))
})
}

Expand Down

0 comments on commit 34e69f2

Please sign in to comment.