Skip to content

Commit

Permalink
Updating tests to have relative timed string for long time test success
Browse files Browse the repository at this point in the history
  • Loading branch information
rajagopal28 committed Aug 1, 2021
1 parent 7e0fe15 commit 081896c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
26 changes: 20 additions & 6 deletions test/app/app_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package service
package app

import (
"testing"
"context"
"time"

"pricingengine"
"pricingengine/service/app"
Expand Down Expand Up @@ -73,8 +74,11 @@ func TestPriceGenerationAppWithActualConfigs(tp *testing.T){

tp.Run("TestPriceGenerationAppToGetValidGeneratedPriceList-FailureScenario-5", func(t *testing.T) {

now := time.Now()
_t := now.AddDate(-15, 0, 0) //15 years before now
dob := _t.Format("2006-01-02")
request := pricingengine.GeneratePricingRequest{
DateOfBirth: "2006-01-02",
DateOfBirth: dob,
InsuranceGroup: 20,
LicenseHeldSince: "2006-01-02",
}
Expand All @@ -89,10 +93,15 @@ func TestPriceGenerationAppWithActualConfigs(tp *testing.T){

tp.Run("TestPriceGenerationAppToGetValidGeneratedPriceList-SuccessScenario-1", func(t *testing.T) {

now := time.Now()
_t := now.AddDate(-20, 0, 0) //20 years before now
dob := _t.Format("2006-01-02")
_t = now.AddDate(-7, 0, 0) //7 years before now
licence := _t.Format("2006-01-02")
request := pricingengine.GeneratePricingRequest{
DateOfBirth: "2001-01-02",
DateOfBirth: dob,
InsuranceGroup: 7,
LicenseHeldSince: "2006-01-02",
LicenseHeldSince: licence,
}
resp,_ := testApp.GeneratePricing(context.Background(),&request)

Expand All @@ -113,10 +122,15 @@ func TestPriceGenerationAppWithActualConfigs(tp *testing.T){
})

tp.Run("TestPriceGenerationAppToGetValidGeneratedPriceList-SuccessScenario-2", func(t *testing.T) {
now := time.Now()
_t := now.AddDate(-20, 0, 0) //20 years before now
dob := _t.Format("2006-01-02")
_t = now.AddDate(-5, 0, 0) //5 years before now
licence := _t.Format("2006-01-02")
request := pricingengine.GeneratePricingRequest{
DateOfBirth: "2001-01-02",
DateOfBirth: dob,
InsuranceGroup: 7,
LicenseHeldSince: "2020-01-02",
LicenseHeldSince: licence,
}
resp,_ := testApp.GeneratePricing(context.Background(),&request)

Expand Down
26 changes: 19 additions & 7 deletions test/service/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"testing"
"fmt"
"time"
"net/http"
"net/http/httptest"
"encoding/json"
Expand Down Expand Up @@ -78,9 +79,11 @@ func TestServiceEndpointsIntegrationTestWithActualConfigs(tp *testing.T){
})

tp.Run("TestRESTAPIEndpointToGetValidGeneratedPriceList-FailureScenario-5", func(t *testing.T) {

now := time.Now()
_t := now.AddDate(-15, 0, 0) //15 years before now
dob := _t.Format("2006-01-02")
request := pricingengine.GeneratePricingRequest{
DateOfBirth: "2006-01-02",
DateOfBirth: dob,
InsuranceGroup: 20,
LicenseHeldSince: "2006-01-02",
}
Expand All @@ -94,11 +97,15 @@ func TestServiceEndpointsIntegrationTestWithActualConfigs(tp *testing.T){


tp.Run("TestRESTAPIEndpointToGetValidGeneratedPriceList-SuccessScenario-1", func(t *testing.T) {

now := time.Now()
_t := now.AddDate(-20, 0, 0) //20 years before now
dob := _t.Format("2006-01-02")
_t = now.AddDate(-7, 0, 0) //7 years before now
licence := _t.Format("2006-01-02")
request := pricingengine.GeneratePricingRequest{
DateOfBirth: "2001-01-02",
DateOfBirth: dob,
InsuranceGroup: 7,
LicenseHeldSince: "2006-01-02",
LicenseHeldSince: licence,
}
resp,_ := MakeHttpRequestAndGetResponse(&request)
println(resp)
Expand All @@ -119,10 +126,15 @@ func TestServiceEndpointsIntegrationTestWithActualConfigs(tp *testing.T){
})

tp.Run("TestRESTAPIEndpointToGetValidGeneratedPriceList-SuccessScenario-2", func(t *testing.T) {
now := time.Now()
_t := now.AddDate(-20, 0, 0) //20 years before now
dob := _t.Format("2006-01-02")
_t = now.AddDate(-5, 0, 0) //5 years before now
licence := _t.Format("2006-01-02")
request := pricingengine.GeneratePricingRequest{
DateOfBirth: "2001-01-02",
DateOfBirth: dob,
InsuranceGroup: 7,
LicenseHeldSince: "2020-01-02",
LicenseHeldSince: licence,
}
resp,_ := MakeHttpRequestAndGetResponse(&request)
println(resp)
Expand Down

0 comments on commit 081896c

Please sign in to comment.