Skip to content

Commit

Permalink
Fixing tests and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Dec 23, 2024
1 parent e036e03 commit d0f09bd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bill/invoice_scenarios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestScenarios(t *testing.T) {
inv := baseInvoiceWithLines(t)
inv.SetTags("random")
assert.NoError(t, inv.Calculate())
assert.ErrorContains(t, inv.Validate(), "$tags: 'random' undefined.")
assert.ErrorContains(t, inv.Validate(), "$tags: (0: 'random' undefined.).")
})

t.Run("scenario for new note", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion bill/invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ func TestInvoiceTagsValidation(t *testing.T) {
inv.SetTags("invalid-tag")
assert.NoError(t, inv.Calculate())
err = inv.ValidateWithContext(ctx)
assert.ErrorContains(t, err, "tags: 'invalid-tag' undefined")
assert.ErrorContains(t, err, "$tags: (0: 'invalid-tag' undefined.).")
}

func baseInvoiceWithLines(t *testing.T) *bill.Invoice {
Expand Down
12 changes: 6 additions & 6 deletions bill/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
)

// ReceiptTypes defines the list of potential payment types.
var ReceiptTypes = []*cbc.KeyDefinition{
var ReceiptTypes = []*cbc.Definition{
{
Key: ReceiptTypePayment,
Name: i18n.String{
Expand Down Expand Up @@ -62,7 +62,7 @@ const (
)

// ReceiptLineTypes defines the list of potential receipt line types.
var ReceiptLineTypes = []*cbc.KeyDefinition{
var ReceiptLineTypes = []*cbc.Definition{
{
Key: ReceiptLineTypeDebit,
Name: i18n.String{
Expand Down Expand Up @@ -214,7 +214,7 @@ func (rct *Receipt) normalizers() tax.Normalizers {
if r := rct.RegimeDef(); r != nil {
normalizers = normalizers.Append(r.Normalizer)
}
for _, a := range rct.GetAddonDefs() {
for _, a := range rct.AddonDefs() {
normalizers = normalizers.Append(a.Normalizer)
}
return normalizers

Check warning on line 220 in bill/receipt.go

View check run for this annotation

Codecov / codecov/patch

bill/receipt.go#L212-L220

Added lines #L212 - L220 were not covered by tests
Expand Down Expand Up @@ -258,7 +258,7 @@ func (rct *Receipt) calculate() error {
}

// JSONSchemaExtend extends the schema with additional property details
func (rt Receipt) JSONSchemaExtend(js *jsonschema.Schema) {
func (rct Receipt) JSONSchemaExtend(js *jsonschema.Schema) {
props := js.Properties
// Extend type list
if its, ok := props.Get("type"); ok {
Expand All @@ -271,8 +271,8 @@ func (rt Receipt) JSONSchemaExtend(js *jsonschema.Schema) {
}
}

Check warning on line 272 in bill/receipt.go

View check run for this annotation

Codecov / codecov/patch

bill/receipt.go#L261-L272

Added lines #L261 - L272 were not covered by tests
}
rt.Regime.JSONSchemaExtend(js)
rt.Addons.JSONSchemaExtend(js)
rct.Regime.JSONSchemaExtend(js)
rct.Addons.JSONSchemaExtend(js)
// Recommendations
js.Extras = map[string]any{
schema.Recommended: []string{
Expand Down
2 changes: 1 addition & 1 deletion bill/receipt_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (rl *ReceiptLine) ValidateWithContext(ctx context.Context) error {
}

// JSONSchemaExtend extends the schema with additional property details
func (rtl ReceiptLine) JSONSchemaExtend(js *jsonschema.Schema) {
func (rl ReceiptLine) JSONSchemaExtend(js *jsonschema.Schema) {
props := js.Properties
// Extend type list
if its, ok := props.Get("type"); ok {
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/bulk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ func TestBulk(t *testing.T) { //nolint:gocyclo
// Following raw message is copied and pasted! (sorry!)
Payload: json.RawMessage(`{
"list": [
"https://gobl.org/draft-0/bill/correction-options", "https://gobl.org/draft-0/bill/invoice", "https://gobl.org/draft-0/cal/date", "https://gobl.org/draft-0/cal/date-time", "https://gobl.org/draft-0/cal/period", "https://gobl.org/draft-0/cbc/code", "https://gobl.org/draft-0/cbc/code-map", "https://gobl.org/draft-0/cbc/definition", "https://gobl.org/draft-0/cbc/key", "https://gobl.org/draft-0/cbc/meta", "https://gobl.org/draft-0/cbc/note", "https://gobl.org/draft-0/currency/amount", "https://gobl.org/draft-0/currency/code", "https://gobl.org/draft-0/currency/exchange-rate", "https://gobl.org/draft-0/dsig/digest", "https://gobl.org/draft-0/dsig/signature", "https://gobl.org/draft-0/envelope", "https://gobl.org/draft-0/head/header", "https://gobl.org/draft-0/head/link", "https://gobl.org/draft-0/head/stamp", "https://gobl.org/draft-0/i18n/string", "https://gobl.org/draft-0/l10n/code", "https://gobl.org/draft-0/l10n/iso-country-code", "https://gobl.org/draft-0/l10n/tax-country-code", "https://gobl.org/draft-0/note/message", "https://gobl.org/draft-0/num/amount", "https://gobl.org/draft-0/num/percentage", "https://gobl.org/draft-0/org/address", "https://gobl.org/draft-0/org/coordinates", "https://gobl.org/draft-0/org/document-ref", "https://gobl.org/draft-0/org/email", "https://gobl.org/draft-0/org/identity", "https://gobl.org/draft-0/org/image", "https://gobl.org/draft-0/org/inbox", "https://gobl.org/draft-0/org/item", "https://gobl.org/draft-0/org/name", "https://gobl.org/draft-0/org/party", "https://gobl.org/draft-0/org/person", "https://gobl.org/draft-0/org/registration", "https://gobl.org/draft-0/org/telephone", "https://gobl.org/draft-0/org/unit", "https://gobl.org/draft-0/org/website", "https://gobl.org/draft-0/pay/advance", "https://gobl.org/draft-0/pay/instructions", "https://gobl.org/draft-0/pay/terms", "https://gobl.org/draft-0/regimes/mx/food-vouchers", "https://gobl.org/draft-0/regimes/mx/fuel-account-balance", "https://gobl.org/draft-0/schema/object", "https://gobl.org/draft-0/tax/addon-def", "https://gobl.org/draft-0/tax/catalogue-def", "https://gobl.org/draft-0/tax/extensions", "https://gobl.org/draft-0/tax/identity", "https://gobl.org/draft-0/tax/regime-def", "https://gobl.org/draft-0/tax/set", "https://gobl.org/draft-0/tax/total"
"https://gobl.org/draft-0/bill/correction-options", "https://gobl.org/draft-0/bill/invoice", "https://gobl.org/draft-0/bill/receipt", "https://gobl.org/draft-0/cal/date", "https://gobl.org/draft-0/cal/date-time", "https://gobl.org/draft-0/cal/period", "https://gobl.org/draft-0/cbc/code", "https://gobl.org/draft-0/cbc/code-map", "https://gobl.org/draft-0/cbc/definition", "https://gobl.org/draft-0/cbc/key", "https://gobl.org/draft-0/cbc/meta", "https://gobl.org/draft-0/cbc/note", "https://gobl.org/draft-0/currency/amount", "https://gobl.org/draft-0/currency/code", "https://gobl.org/draft-0/currency/exchange-rate", "https://gobl.org/draft-0/dsig/digest", "https://gobl.org/draft-0/dsig/signature", "https://gobl.org/draft-0/envelope", "https://gobl.org/draft-0/head/header", "https://gobl.org/draft-0/head/link", "https://gobl.org/draft-0/head/stamp", "https://gobl.org/draft-0/i18n/string", "https://gobl.org/draft-0/l10n/code", "https://gobl.org/draft-0/l10n/iso-country-code", "https://gobl.org/draft-0/l10n/tax-country-code", "https://gobl.org/draft-0/note/message", "https://gobl.org/draft-0/num/amount", "https://gobl.org/draft-0/num/percentage", "https://gobl.org/draft-0/org/address", "https://gobl.org/draft-0/org/coordinates", "https://gobl.org/draft-0/org/document-ref", "https://gobl.org/draft-0/org/email", "https://gobl.org/draft-0/org/identity", "https://gobl.org/draft-0/org/image", "https://gobl.org/draft-0/org/inbox", "https://gobl.org/draft-0/org/item", "https://gobl.org/draft-0/org/name", "https://gobl.org/draft-0/org/party", "https://gobl.org/draft-0/org/person", "https://gobl.org/draft-0/org/registration", "https://gobl.org/draft-0/org/telephone", "https://gobl.org/draft-0/org/unit", "https://gobl.org/draft-0/org/website", "https://gobl.org/draft-0/pay/advance", "https://gobl.org/draft-0/pay/instructions", "https://gobl.org/draft-0/pay/terms", "https://gobl.org/draft-0/regimes/mx/food-vouchers", "https://gobl.org/draft-0/regimes/mx/fuel-account-balance", "https://gobl.org/draft-0/schema/object", "https://gobl.org/draft-0/tax/addon-def", "https://gobl.org/draft-0/tax/catalogue-def", "https://gobl.org/draft-0/tax/extensions", "https://gobl.org/draft-0/tax/identity", "https://gobl.org/draft-0/tax/regime-def", "https://gobl.org/draft-0/tax/set", "https://gobl.org/draft-0/tax/total"
]
}`),
IsFinal: false,
Expand Down
4 changes: 2 additions & 2 deletions tax/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestTagSetForSchema(t *testing.T) {
ts1 := &tax.TagSet{
Schema: "bill/invoice",
List: []*cbc.KeyDefinition{
List: []*cbc.Definition{
{
Key: "test1",
Name: i18n.String{
Expand All @@ -24,7 +24,7 @@ func TestTagSetForSchema(t *testing.T) {
}
ts2 := &tax.TagSet{
Schema: "bill/receipt",
List: []*cbc.KeyDefinition{
List: []*cbc.Definition{
{
Key: "test2",
Name: i18n.String{
Expand Down

0 comments on commit d0f09bd

Please sign in to comment.