Documentation ¶
Overview ¶
Description: This package provides mock data for testing purposes. It provides functions to mock the behavior of Go's JSON decoder, specifically when `json.Number` is enabled. This allows for precise testing of code that relies on the exact data structures and types produced by the standard JSON decoder.
This package is primarily used in development and staging environments to mimic real HTTP requests and their decoded responses, simplifying testing without requiring actual network calls. In production, real http requests are used.
When decoding JSON with `json.Number` enabled: - Numbers are decoded as `json.Number` - Slices are decoded as `[]interface{}` - Objects, and maps, are decoded as `map[string]interface{}`
Example:
{ "name": "Alice", "age": 30, "score": "1234567890123456789", "scores": [95.5, 88, 92.1] }
Decodes to: - `name`: `string` - `age`: `json.Number` - `score`: `json.Number` - `scores`: `[]interface{}` (each element is `json.Number`)
Index ¶
Constants ¶
const ( ProductNameKey = "product_name" AppliedTaxesKey = "applied_taxes" QuantityKey = "quantity" QuantifierNameKey = "quantifier_name" UnitPriceKey = "unit_price" SubTotalKey = "sub_total" TaxTotalKey = "tax_total" TotalKey = "total" DetailsKey = "details" TotalImplicitSubTotalKey = "sub_total" TotalImplicitTaxDetailsKey = "tax_details" TotalImplicitTaxTotalKey = "tax_total" TotalImplicitTotalKey = "total" TaxDetailTaxIDKey = "tax_id" TaxDetailTaxTotalKey = "tax_total" TaxDetailTaxNameKey = "tax_name" TaxNameKey = "name" TaxAuthorIDKey = "author_id" TaxDescriptionKey = "description" TaxRateKey = "rate" TaxIDKey = "tax_id" TaxSchemaVersionKey = "schema_version" TaxUpdatedAtKey = "updated_at" TaxCreatedAtKey = "created_at" BillNumberKey = "number" BillStartPeriodKey = "start_period" BillEndPeriodKey = "end_period" BillYearKey = "year" BillSalaryEntriesKey = "salary_entries" BillTransportationEntriesKey = "transportation_entries" BillChargeEntriesKey = "charge_entries" BillSupInvoiceEntriesKey = "sup_invoice_entries" BillSalaryTotalKey = "salary_total" BillTransportationTotalKey = "transportation_total" BillChargeTotalKey = "charge_total" BillSupInvoiceTotalKey = "sup_invoice_total" BillTotalKey = "total" BillUpfrontKey = "upfront" BillBalanceKey = "balance" BillTitleKey = "title" BillTypeKey = "bill_type" BillStartDateKey = "start_date" BillEndDateKey = "end_date" BillAuthorIDKey = "author_id" BillClientIDKey = "client_id" BillWorksiteIDKey = "worksite_id" BillTimezoneKey = "timezone" BillSalaryTaxesKey = "salary_taxes" BillSupInvoiceTaxesKey = "sup_invoice_taxes" BillChargeTaxesKey = "charge_taxes" BillTopNoteKey = "top_note" BillExcludeChargedKey = "exclude_charged" BillIsEstimateKey = "is_estimate" BillIsInternalKey = "is_internal" BillIncludeTransportationKey = "include_transportation" BillIncludeSalaryKey = "include_salary" BillIncludeSupInvoiceKey = "include_sup_invoice" BillIncludeChargeKey = "include_charge" BillIsCanceledKey = "is_canceled" BillIsAchievedKey = "is_achieved" BillUpfrontRateKey = "upfront_rate" BillDueDateKey = "due_date" BillDueDateStrKey = "due_date_str" BillDefaultSupplierInvoiceRateKey = "default_supplier_invoice_rate" BillTypeFixedValue = "fixed" BillTypeDynamicValue = "dynamic" BillChargeQuantifierNameForEquipmentHour = "hour" BillChargeQuantifierNameForEquipmentDay = "day" BillChargeQuantifierNameForProduct = "Boite 50 Lbs" )
const ( // General keys. IDKey = "_id" SchemaVersionKey = "schema_version" UpdatedAtKey = "updated_at" CreatedAtKey = "created_at" // General values. CurrencyValue = "USD" SchemaVersionValue = "v1" YearValue = json.Number("2024") IDValue = "5f6d4b9b9c6f9f0001b9c6f9" )
const ( // General keys. OwnerIDKey = "owner_id" // Payroll keys. PayrollYearKey = "year" PayrollPeriodsKey = "periods" PayrollCurrencyCodeKey = "currency_code" PayrollHourbankIDKey = "hourbank_id" PayrollEmployeeIDKey = "employee_id" PayrollSummaryIDsKey = "summary_ids" PayrollIsBankedKey = "is_banked" PayrollWorkAmountKey = "work_amount" PayrollTransportAmountKey = "transport_amount" PayrollGrossPayrollAmountKey = "gross_payroll_amount" PayrollDeductionAmountKey = "deduction_amount" PayrollContributionAmountKey = "contribution_amount" PayrollNetPayrollAmountKey = "net_payroll_amount" PayrollIsProblematicKey = "is_problematic" PayrollEmployeeConfigIDKey = "employee_config_id" PayrollDeductionAndContributionAmountKey = "deduction_and_contribution_amount" // DeductionEntry keys. DeductionEntryCurrencyCodeKey = "currency_code" DeductionEntryEmployeeIDKey = "employee_id" DeductionEntryYearKey = "year" DeductionEntryPeriodKey = "period" DeductionEntryPayrollIDKey = "payroll_id" DeductionEntryDeductionAmountsKey = "deduction_amounts" DeductionEntryContributionAmountsKey = "contribution_amounts" DeductionEntryDeductionTotalAmountKey = "deduction_total_amount" DeductionEntryContributionTotalAmountKey = "contribution_total_amount" DeductionEntryTotalAmountKey = "total_amount" // DeductionAmount keys. DeductionAmountNameKey = "name" DeductionAmountDeductionIDKey = "deduction_id" DeductionAmountAmountKey = "amount" DeductionAmountIsSubContributionKey = "is_sub_contribution" // DeductionAggregation keys. DeductionAggregationOwnerIDKey = "owner_id" DeductionAggregationCurrencyCodeKey = "currency_code" DeductionAggregationYearKey = "year" DeductionAggregationPeriodsKey = "periods" DeductionAggregationDeductionEntryIDsKey = "deduction_entry_ids" DeductionAggregationDeductionTotalPerPeriodKey = "deduction_total_per_period" DeductionAggregationContributionTotalPerPeriodKey = "contribution_total_per_period" DeductionAggregationDeductionAmountsPerPeriodKey = "deduction_amounts_per_period" DeductionAggregationContributionAmountsPerPeriodKey = "contribution_amounts_per_period" DeductionAggregationTotalPerDeductionKey = "total_per_deduction" DeductionAggregationTotalPerContributionKey = "total_per_contribution" DeductionAggregationDeductionAmountsKey = "deduction_amounts" DeductionAggregationContributionAmountsKey = "contribution_amounts" DeductionAggregationDeductionTotalAmountKey = "deduction_total_amount" DeductionAggregationContributionTotalAmountKey = "contribution_total_amount" DeductionAggregationTotalAmountKey = "total_amount" DeductionAggregationEmployeeIDsKey = "employee_ids" DeductionAggregationTotalPerGroupKey = "total_per_group" )
Define constants for all keys.
Variables ¶
var BillMock = map[string]interface{}{ IDKey: IDValue, SchemaVersionKey: SchemaVersionValue, UpdatedAtKey: "2020-10-05T10:00:00Z", CreatedAtKey: "2020-10-05T10:00:00Z", BillNumberKey: json.Number("18342394"), BillStartPeriodKey: json.Number("30"), BillEndPeriodKey: json.Number("35"), BillYearKey: YearValue, BillSalaryEntriesKey: getSlice(SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock, SalaryEntryMock), BillTransportationEntriesKey: getSlice(SalaryEntryMock, SalaryEntryMock, SalaryEntryMock), BillChargeEntriesKey: getSlice( CreditEntryMock, ChargeEntryMock("Clous 2 pouces", BillChargeQuantifierNameForProduct), ChargeEntryMock("Vis à tôle bleue", BillChargeQuantifierNameForProduct), ChargeEntryMock("Clous 3 pouces", BillChargeQuantifierNameForProduct), ChargeEntryMock("Clous 4 pouces", BillChargeQuantifierNameForProduct), ChargeEntryMock("Clous 5 pouces", BillChargeQuantifierNameForProduct), ChargeEntryMock("Clous 6 pouces", BillChargeQuantifierNameForProduct), ChargeEntryMock("Clous à finir", BillChargeQuantifierNameForProduct), ChargeEntryMock("RedLift 25", BillChargeQuantifierNameForEquipmentDay), ChargeEntryMock("Plafolift 4", BillChargeQuantifierNameForEquipmentHour), ChargeEntryMock("Roulette de tape", BillChargeQuantifierNameForProduct), ChargeEntryMock("RedLift 55", BillChargeQuantifierNameForEquipmentDay), ChargeEntryMock("Plafolift Électrique", BillChargeQuantifierNameForEquipmentHour), ), BillSupInvoiceEntriesKey: getSlice(SupInvoiceEntryMock, SupInvoiceEntryMock, SupInvoiceEntryMock, SupInvoiceEntryMock, SupInvoiceEntryMock), BillSalaryTotalKey: TotalImplicitMock, BillTransportationTotalKey: TotalImplicitMock, BillChargeTotalKey: TotalImplicitMock, BillSupInvoiceTotalKey: TotalImplicitMock, BillTotalKey: TotalImplicitMock, BillUpfrontKey: json.Number("2000"), BillBalanceKey: json.Number("6000"), BillTitleKey: "Construction d'un Poulailler de 200 Pieds & 2 Étages", BillTypeKey: BillTypeFixedValue, BillStartDateKey: "2020-10-05T14:00:00Z", BillEndDateKey: "2020-10-05T14:00:00Z", BillAuthorIDKey: "5f7b1b9b9b9b9b9b9b9b9b9b", BillClientIDKey: "5f7b1b9b9b9b9b9b9b9b9b9b", BillWorksiteIDKey: "5f7b1b9b9b9b9b9b9b9b9b9b", BillTimezoneKey: "America/New_York", BillSalaryTaxesKey: getSlice(TaxMock), BillSupInvoiceTaxesKey: getSlice(TaxMock), BillChargeTaxesKey: getSlice(TaxMock), BillTopNoteKey: "Ceci est une note.", BillExcludeChargedKey: true, BillIsEstimateKey: true, BillIsInternalKey: true, BillIncludeTransportationKey: true, BillIncludeSalaryKey: true, BillIncludeSupInvoiceKey: true, BillIncludeChargeKey: true, BillIsCanceledKey: false, BillUpfrontRateKey: json.Number("2000"), BillDueDateKey: "2020-10-05T14:00:00Z", BillDueDateStrKey: "30 days post-completion", BillIsAchievedKey: true, BillDefaultSupplierInvoiceRateKey: json.Number("4000"), }
Mock data for model.Bill.
var ChargeEntryMock = func(itemName, quantifierName string) map[string]interface{} { return map[string]interface{}{ ProductNameKey: itemName, AppliedTaxesKey: getSlice("TPS", "TVQ"), QuantityKey: json.Number("1.25"), QuantifierNameKey: quantifierName, UnitPriceKey: json.Number("4550"), SubTotalKey: json.Number("10000"), TaxTotalKey: json.Number("1400"), TotalKey: json.Number("11400"), DetailsKey: "", } }
Mock data for charge emb.Entry.
var ContributionAmountsMock = getSlice( map[string]interface{}{ DeductionAmountNameKey: "Contribution 1", DeductionAmountDeductionIDKey: primitive.NewObjectID().Hex(), DeductionAmountAmountKey: json.Number("1000"), DeductionAmountIsSubContributionKey: false, }, map[string]interface{}{ DeductionAmountNameKey: "Contribution 2", DeductionAmountDeductionIDKey: primitive.NewObjectID().Hex(), DeductionAmountAmountKey: json.Number("1000"), DeductionAmountIsSubContributionKey: false, }, map[string]interface{}{ DeductionAmountNameKey: "Sub-Contribution 1", DeductionAmountDeductionIDKey: primitive.NewObjectID().Hex(), DeductionAmountAmountKey: json.Number("400"), DeductionAmountIsSubContributionKey: true, }, map[string]interface{}{ DeductionAmountNameKey: "Sub-Contribution 2", DeductionAmountDeductionIDKey: primitive.NewObjectID().Hex(), DeductionAmountAmountKey: json.Number("500"), DeductionAmountIsSubContributionKey: true, }, )
var CreditEntryMock = map[string]interface{}{ ProductNameKey: "Clous 3 Pouces", AppliedTaxesKey: getSlice("TPS", "TVQ"), QuantityKey: json.Number("-3.50"), QuantifierNameKey: "Boite 50 Lbs", UnitPriceKey: json.Number("4550"), SubTotalKey: json.Number("-100000"), TaxTotalKey: json.Number("-14000"), TotalKey: json.Number("-114000"), DetailsKey: "", }
Mock data for credit emb.Entry.
var ( DeductionAggregationMock = map[string]interface{}{ IDKey: IDValue, SchemaVersionKey: SchemaVersionValue, UpdatedAtKey: time.Now().UTC().Format(time.RFC3339), CreatedAtKey: time.Now().UTC().Format(time.RFC3339), DeductionAggregationOwnerIDKey: primitive.NewObjectID().Hex(), DeductionAggregationCurrencyCodeKey: CurrencyValue, DeductionAggregationYearKey: YearValue, DeductionAggregationPeriodsKey: getSlice(json.Number("1"), json.Number("2")), DeductionAggregationDeductionEntryIDsKey: getSlice(primitive.NewObjectID().Hex(), primitive.NewObjectID().Hex()), DeductionAggregationDeductionTotalPerPeriodKey: map[intKey]interface{}{"1": json.Number("8900"), "2": json.Number("8900")}, DeductionAggregationContributionTotalPerPeriodKey: map[intKey]interface{}{"1": json.Number("2000"), "2": json.Number("2000")}, DeductionAggregationDeductionAmountsPerPeriodKey: map[intKey]interface{}{ "1": DeductionAmountsMock, "2": DeductionAmountsMock, }, DeductionAggregationContributionAmountsPerPeriodKey: map[intKey]interface{}{ "1": ContributionAmountsMock, "2": ContributionAmountsMock, }, DeductionAggregationTotalPerDeductionKey: map[string]interface{}{ "Deduction 1": json.Number("8000"), "Deduction 2": json.Number("8000"), "Sub-Contribution 1": json.Number("800"), "Sub-Contribution 2": json.Number("1000"), }, DeductionAggregationTotalPerContributionKey: map[string]interface{}{ "Contribution 1": json.Number("2000"), "Contribution 2": json.Number("2000"), }, DeductionAggregationTotalPerGroupKey: map[string]interface{}{ "Federal": json.Number("5000"), "State": json.Number("13600"), "Other": json.Number("5000"), }, DeductionAggregationDeductionAmountsKey: append(DeductionAmountsMock, DeductionAmountsMock...), DeductionAggregationContributionAmountsKey: append(ContributionAmountsMock, ContributionAmountsMock...), DeductionAggregationDeductionTotalAmountKey: json.Number("17800"), DeductionAggregationContributionTotalAmountKey: json.Number("5800"), DeductionAggregationTotalAmountKey: json.Number("23600"), DeductionAggregationEmployeeIDsKey: getSlice(primitive.NewObjectID().Hex(), primitive.NewObjectID().Hex()), } )
Mocked data for the model.DeductionAggregation.
var DeductionAmountsMock = getSlice( map[string]interface{}{ DeductionAmountNameKey: "Deduction 1", DeductionAmountDeductionIDKey: primitive.NewObjectID().Hex(), DeductionAmountAmountKey: json.Number("4000"), DeductionAmountIsSubContributionKey: false, }, map[string]interface{}{ DeductionAmountNameKey: "Deduction 2", DeductionAmountDeductionIDKey: primitive.NewObjectID().Hex(), DeductionAmountAmountKey: json.Number("4000"), DeductionAmountIsSubContributionKey: false, }, )
var DeductionEntryMock = func(period json.Number) map[string]interface{} { return map[string]interface{}{ IDKey: primitive.NewObjectID().Hex(), SchemaVersionKey: SchemaVersionValue, UpdatedAtKey: time.Now().UTC().Format(time.RFC3339), CreatedAtKey: time.Now().UTC().Format(time.RFC3339), OwnerIDKey: primitive.NewObjectID().Hex(), DeductionEntryCurrencyCodeKey: CurrencyValue, DeductionEntryEmployeeIDKey: primitive.NewObjectID().Hex(), DeductionEntryYearKey: YearValue, DeductionEntryPeriodKey: period, DeductionEntryPayrollIDKey: primitive.NewObjectID().Hex(), DeductionEntryDeductionAmountsKey: DeductionAmountsMock, DeductionEntryContributionAmountsKey: ContributionAmountsMock, DeductionEntryDeductionTotalAmountKey: json.Number("8900"), DeductionEntryContributionTotalAmountKey: json.Number("2000"), DeductionEntryTotalAmountKey: json.Number("10900"), } }
Mock data for the model.DeductionEntry.
var ( PayrollMock = map[string]interface{}{ IDKey: IDValue, SchemaVersionKey: SchemaVersionValue, UpdatedAtKey: time.Now().UTC().Format(time.RFC3339), CreatedAtKey: time.Now().UTC().Format(time.RFC3339), PayrollHourbankIDKey: primitive.NewObjectID().Hex(), PayrollEmployeeIDKey: primitive.NewObjectID().Hex(), PayrollSummaryIDsKey: getSlice(primitive.NewObjectID().Hex(), primitive.NewObjectID().Hex()), PayrollIsBankedKey: true, PayrollIsProblematicKey: false, PayrollWorkAmountKey: json.Number("150000"), PayrollTransportAmountKey: json.Number("50000"), PayrollGrossPayrollAmountKey: json.Number("200000"), PayrollDeductionAmountKey: json.Number("30000"), PayrollContributionAmountKey: json.Number("20000"), PayrollDeductionAndContributionAmountKey: json.Number("50000"), PayrollNetPayrollAmountKey: json.Number("170000"), PayrollEmployeeConfigIDKey: primitive.NewObjectID().Hex(), OwnerIDKey: primitive.NewObjectID().Hex(), PayrollYearKey: YearValue, PayrollPeriodsKey: getSlice(json.Number("1"), json.Number("2"), json.Number("3"), json.Number("4")), PayrollCurrencyCodeKey: CurrencyValue, } )
Mock data for the model.Payroll.
var SalaryEntryMock = map[string]interface{}{ ProductNameKey: "Olivier Bernard", AppliedTaxesKey: getSlice("TPS", "TVQ"), QuantityKey: json.Number("30.50"), QuantifierNameKey: "h", UnitPriceKey: json.Number("6000"), SubTotalKey: json.Number("10000"), TaxTotalKey: json.Number("1400"), TotalKey: json.Number("11400"), DetailsKey: "2021-11-01 / 2021-11-07 (32)", }
Mock data for the salary emb.Entry.
var SupInvoiceEntryMock = map[string]interface{}{ ProductNameKey: "Les Entreprises Bob Lafortune Inc.", AppliedTaxesKey: getSlice("TPS", "TVQ"), QuantityKey: json.Number("1"), QuantifierNameKey: "", UnitPriceKey: json.Number("4550"), SubTotalKey: json.Number("10000"), TaxTotalKey: json.Number("1400"), TotalKey: json.Number("11400"), DetailsKey: "F183423", }
Mock data for supinvoice emb.Entry.
var TaxDetailMockTPS = map[string]interface{}{ TaxDetailTaxIDKey: "5f7b1b9b9b9b9b9b9b9b9b9b", TaxDetailTaxTotalKey: json.Number("2450"), TaxDetailTaxNameKey: "TPS", }
Mock data for emb.TaxDetail.
var TaxDetailMockTVQ = map[string]interface{}{ TaxDetailTaxIDKey: "5f7b1b9b9b9b9b9b9b9b9b9b", TaxDetailTaxTotalKey: json.Number("2450"), TaxDetailTaxNameKey: "TVQ", }
Mock data for emb.TaxDetail.
var TaxMock = map[string]interface{}{ TaxNameKey: "TPS", TaxAuthorIDKey: "5f7b1b9b9b9b9b9b9b9b9b9b", TaxDescriptionKey: "Taxes sur les produits et services", TaxRateKey: json.Number("5000"), TaxIDKey: "5f7b1b9b9b9b9b9b9b9b9b9b", TaxSchemaVersionKey: SchemaVersionValue, TaxUpdatedAtKey: "2020-10-05T10:00:00Z", TaxCreatedAtKey: "2020-10-05T10:00:00Z", }
Mock data for emb.Tax.
var TotalImplicitMock = map[string]interface{}{ TotalImplicitSubTotalKey: json.Number("10000"), TotalImplicitTaxDetailsKey: getSlice( TaxDetailMockTPS, TaxDetailMockTVQ, ), TotalImplicitTaxTotalKey: json.Number("1400"), TotalImplicitTotalKey: json.Number("11400"), }
Mock data for emb.TotalImplicit.
Functions ¶
This section is empty.
Types ¶
This section is empty.