mockcup

package
v1.36.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 3 Imported by: 0

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

View Source
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"
)
View Source
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"
)
View Source
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

View Source
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.

View Source
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.

View Source
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.

View Source
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.

Mock data for the model.DeductionEntry.

Mock data for the model.Payroll.

View Source
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.

View Source
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.

View Source
var TaxDetailMockTPS = map[string]interface{}{
	TaxDetailTaxIDKey:    "5f7b1b9b9b9b9b9b9b9b9b9b",
	TaxDetailTaxTotalKey: json.Number("2450"),
	TaxDetailTaxNameKey:  "TPS",
}

Mock data for emb.TaxDetail.

View Source
var TaxDetailMockTVQ = map[string]interface{}{
	TaxDetailTaxIDKey:    "5f7b1b9b9b9b9b9b9b9b9b9b",
	TaxDetailTaxTotalKey: json.Number("2450"),
	TaxDetailTaxNameKey:  "TVQ",
}

Mock data for emb.TaxDetail.

View Source
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.

Mock data for emb.TotalImplicit.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL