Skip to content

Commit

Permalink
Update tests to be system independent >.<
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyTetrahedron committed Nov 15, 2023
1 parent 6f5c904 commit 3402aa6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions pkg/odoo/odoo16.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ type apiObject struct {
}

type OdooMeteredBillingRecord struct {
ProductID string `json:"product_id"`
InstanceID string `json:"instance_id"`
ItemDescription string `json:"item_description,omitempty"`
ItemGroupDescription string `json:"item_group_description,omitempty"`
SalesOrderID string `json:"sales_order_id"`
UnitID string `json:"unit_id"`
ConsumedUnits float64 `json:"consumed_units"`
Timerange Timerange `json:"timerange"`
ProductID string `json:"product_id"`
InstanceID string `json:"instance_id"`
ItemDescription string `json:"item_description,omitempty"`
ItemGroupDescription string `json:"item_group_description,omitempty"`
SalesOrderID string `json:"sales_order_id"`
UnitID string `json:"unit_id"`
ConsumedUnits float64 `json:"consumed_units"`
Timerange Timerange `json:"timerange"`
}

type Timerange struct {
From time.Time
To time.Time
To time.Time
}

func (t Timerange) MarshalJSON() ([]byte, error) {
return []byte(`"` + t.From.Format(time.RFC3339) + "/" + t.To.Format(time.RFC3339) + `"`), nil
return []byte(`"` + t.From.Format(time.RFC3339) + "/" + t.To.Format(time.RFC3339) + `"`), nil
}

func (t *Timerange) UnmarshalJSON([]byte) (error) {
func (t *Timerange) UnmarshalJSON([]byte) error {
return errors.New("Not implemented")
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/odoo/odoo16_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestOdooRecordsSent(t *testing.T) {
err := uut.SendData(context.Background(), []odoo.OdooMeteredBillingRecord{getOdooRecord()})

require.NoError(t, err)
require.Equal(t, `{"data":[{"product_id":"my-product","instance_id":"my-instance","item_description":"my-description","item_group_description":"my-group","sales_order_id":"SO00000","unit_id":"my-unit","consumed_units":11.1,"timerange":"2022-02-22T22:22:22+01:00/2022-02-22T23:22:22+01:00"}]}`, mrt.receivedContent)
require.Equal(t, `{"data":[{"product_id":"my-product","instance_id":"my-instance","item_description":"my-description","item_group_description":"my-group","sales_order_id":"SO00000","unit_id":"my-unit","consumed_units":11.1,"timerange":"2022-02-22T22:22:22Z/2022-02-22T23:22:22Z"}]}`, mrt.receivedContent)
}

func TestErrorHandling(t *testing.T) {
Expand Down Expand Up @@ -122,9 +122,9 @@ func getOdooRecord() odoo.OdooMeteredBillingRecord {
ItemDescription: "my-description",
ItemGroupDescription: "my-group",
ConsumedUnits: 11.1,
Timerange: odoo.Timerange{
From: time.Date(2022, 2, 22, 22, 22, 22, 222, time.Local),
To: time.Date(2022, 2, 22, 23, 22, 22, 222, time.Local),
Timerange: odoo.Timerange{
From: time.Date(2022, 2, 22, 22, 22, 22, 222, time.UTC),
To: time.Date(2022, 2, 22, 23, 22, 22, 222, time.UTC),
},
}
}

0 comments on commit 3402aa6

Please sign in to comment.