Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sbryzak committed Jun 17, 2024
1 parent 44bb712 commit 41085ca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/signup/service/signup_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1241,10 +1241,15 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() {

us := s.newUserSignupComplete()
us.Name = service.EncodeUserIdentifier(us.Spec.IdentityClaims.PreferredUsername)
// Set the scheduled deactivation timestamp 1 day ago
us.Status.ScheduledDeactivationTimestamp = util.Ptr(v1.NewTime(time.Now().Add(-time.Hour * 24)))
err := s.FakeUserSignupClient.Tracker.Add(us)
require.NoError(s.T(), err)

mur := s.newProvisionedMUR("ted")
// Set the provisioned time 31 days in the past
provisionedTime := time.Now().Add(-time.Hour * 24 * 31).Round(time.Second)
mur.Status.ProvisionedTime = util.Ptr(v1.NewTime(provisionedTime))
err = s.FakeMasterUserRecordClient.Tracker.Add(mur)
require.NoError(s.T(), err)

Expand Down Expand Up @@ -1276,6 +1281,20 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() {
require.NoError(s.T(), err)
require.NotNil(s.T(), response)

// Confirm the StartDate is the same as the provisionedTime
responseStartDate, err := time.Parse(time.RFC3339, response.StartDate)
require.NoError(s.T(), err)
require.Equal(s.T(), provisionedTime, responseStartDate)

// Confirm the end date is about 1 day ago
responseEndDate, err := time.Parse(time.RFC3339, response.EndDate)
require.NoError(s.T(), err)
expectedEndDate := time.Now().Add(-time.Hour * 24)
require.WithinDuration(s.T(), expectedEndDate, responseEndDate, time.Minute*5,
"endDate in response [%s] not in expected range [%s]", responseEndDate, expectedEndDate.Format(time.RFC3339))

// DaysRemaining should be zero
require.Equal(s.T(), float64(0), *response.DaysRemaining)

Check failure on line 1297 in pkg/signup/service/signup_service_test.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint

float-compare: use require.InEpsilon (or InDelta) (testifylint)
require.Equal(s.T(), us.Name, response.Name)
require.Equal(s.T(), "jsmith", response.Username)
require.Equal(s.T(), "ted", response.CompliantUsername)
Expand Down

0 comments on commit 41085ca

Please sign in to comment.