diff --git a/Makefile b/Makefile index a9718c7..4c42774 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,13 @@ generate: deps mockgen --destination ./internal/mocks/ssl_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/ssl_certificates.go mockgen --destination ./internal/mocks/load_balancers_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/load_balancers.go mockgen --destination ./internal/mocks/racks_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/racks.go + mockgen --destination ./internal/mocks/invoices_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/invoices.go sed -i '' 's|github.com/serverscom/srvctl/vendor/github.com/serverscom/serverscom-go-client/pkg|github.com/serverscom/serverscom-go-client/pkg|g' \ ./internal/mocks/ssh_service.go \ ./internal/mocks/hosts_service.go \ ./internal/mocks/ssl_service.go \ ./internal/mocks/load_balancers_service.go \ ./internal/mocks/racks_service.go \ + ./internal/mocks/invoices_service.go \ ./internal/mocks/collection.go diff --git a/cmd/base/list_options.go b/cmd/base/list_options.go index c1cdaa9..f3fd71e 100644 --- a/cmd/base/list_options.go +++ b/cmd/base/list_options.go @@ -126,3 +126,94 @@ func (o *ClusterIDOption[T]) ApplyToCollection(collection serverscom.Collection[ collection.SetParam("cluster_id", o.clusterID) } } + +// status option +type StatusOption[T any] struct { + status string +} + +func (o *StatusOption[T]) AddFlags(cmd *cobra.Command) { + cmd.Flags().StringVar(&o.status, "status", "", "Filter results by status") +} + +func (o *StatusOption[T]) ApplyToCollection(collection serverscom.Collection[T]) { + if o.status != "" { + collection.SetParam("status", o.status) + } +} + +// invoice type option +type InvoiceTypeOption[T any] struct { + typeVal string +} + +// use itype instead of type to avoid conflict with baseList 'type' hidden flag which we use for subcommands +func (o *InvoiceTypeOption[T]) AddFlags(cmd *cobra.Command) { + cmd.Flags().StringVar(&o.typeVal, "itype", "", "Filter results by type") +} + +func (o *InvoiceTypeOption[T]) ApplyToCollection(collection serverscom.Collection[T]) { + if o.typeVal != "" { + collection.SetParam("type", o.typeVal) + } +} + +// parent id option +type ParentIDOption[T any] struct { + parentID string +} + +func (o *ParentIDOption[T]) AddFlags(cmd *cobra.Command) { + cmd.Flags().StringVar(&o.parentID, "parent-id", "", "Filter results by parent ID") +} + +func (o *ParentIDOption[T]) ApplyToCollection(collection serverscom.Collection[T]) { + if o.parentID != "" { + collection.SetParam("parent_id", o.parentID) + } +} + +// currency option +type CurrencyOption[T any] struct { + currency string +} + +func (o *CurrencyOption[T]) AddFlags(cmd *cobra.Command) { + cmd.Flags().StringVar(&o.currency, "currency", "", "Filter results by currency") +} + +func (o *CurrencyOption[T]) ApplyToCollection(collection serverscom.Collection[T]) { + if o.currency != "" { + collection.SetParam("currency", o.currency) + } +} + +// start date option +type StartDateOption[T any] struct { + startDate string +} + +func (o *StartDateOption[T]) AddFlags(cmd *cobra.Command) { + cmd.Flags().StringVar(&o.startDate, "start-date", "", "Filter results by start date") +} + +func (o *StartDateOption[T]) ApplyToCollection(collection serverscom.Collection[T]) { + if o.startDate != "" { + collection.SetParam("start_date", o.startDate) + } +} + +// end date option +type EndDateOption[T any] struct { + endDate string +} + +func (o *EndDateOption[T]) AddFlags(cmd *cobra.Command) { + cmd.Flags().StringVar(&o.endDate, "end-date", "", "Filter results by end date") +} + +func (o *EndDateOption[T]) ApplyToCollection(collection serverscom.Collection[T]) { + if o.endDate != "" { + collection.SetParam("end_date", o.endDate) + } +} diff --git a/cmd/entities/invoices/get.go b/cmd/entities/invoices/get.go new file mode 100644 index 0000000..5300538 --- /dev/null +++ b/cmd/entities/invoices/get.go @@ -0,0 +1,39 @@ +package invoices + +import ( + "github.com/serverscom/srvctl/cmd/base" + "github.com/spf13/cobra" +) + +func newGetCmd(cmdContext *base.CmdContext) *cobra.Command { + cmd := &cobra.Command{ + Use: "get ", + Short: "Get an invoice", + Long: "Get an invoice by id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + manager := cmdContext.GetManager() + + ctx, cancel := base.SetupContext(cmd, manager) + defer cancel() + + base.SetupProxy(cmd, manager) + + scClient := cmdContext.GetClient().SetVerbose(manager.GetVerbose(cmd)).GetScClient() + + id := args[0] + invoice, err := scClient.Invoices.GetBillingInvoice(ctx, id) + if err != nil { + return err + } + + if invoice != nil { + formatter := cmdContext.GetOrCreateFormatter(cmd) + return formatter.Format(invoice) + } + return nil + }, + } + + return cmd +} diff --git a/cmd/entities/invoices/invoices.go b/cmd/entities/invoices/invoices.go new file mode 100644 index 0000000..d097180 --- /dev/null +++ b/cmd/entities/invoices/invoices.go @@ -0,0 +1,38 @@ +package invoices + +import ( + "log" + + serverscom "github.com/serverscom/serverscom-go-client/pkg" + "github.com/serverscom/srvctl/cmd/base" + "github.com/serverscom/srvctl/internal/output/entities" + "github.com/spf13/cobra" +) + +func NewCmd(cmdContext *base.CmdContext) *cobra.Command { + invoiceEntity, err := entities.Registry.GetEntityFromValue(serverscom.Invoice{}) + if err != nil { + log.Fatal(err) + } + entitiesMap := make(map[string]entities.EntityInterface) + entitiesMap["invoices"] = invoiceEntity + cmd := &cobra.Command{ + Use: "invoices", + Short: "Manage invoices", + PersistentPreRunE: base.CombinePreRunE( + base.CheckFormatterFlags(cmdContext, entitiesMap), + base.CheckEmptyContexts(cmdContext), + ), + Args: base.NoArgs, + Run: base.UsageRun, + } + + cmd.AddCommand( + newListCmd(cmdContext), + newGetCmd(cmdContext), + ) + + base.AddFormatFlags(cmd) + + return cmd +} diff --git a/cmd/entities/invoices/invoices_test.go b/cmd/entities/invoices/invoices_test.go new file mode 100644 index 0000000..b791027 --- /dev/null +++ b/cmd/entities/invoices/invoices_test.go @@ -0,0 +1,251 @@ +package invoices + +import ( + "errors" + "path/filepath" + "testing" + + . "github.com/onsi/gomega" + serverscom "github.com/serverscom/serverscom-go-client/pkg" + "github.com/serverscom/srvctl/cmd/testutils" + "github.com/serverscom/srvctl/internal/mocks" + "go.uber.org/mock/gomock" +) + +var ( + testId = "testId" + fixtureBasePath = filepath.Join("..", "..", "..", "testdata", "entities", "invoices") + testInvoice = serverscom.Invoice{ + ID: testId, + Number: 123, + Status: "paid", + Date: "2025-01-01", + Type: "1", + TotalDue: 1.23, + Currency: "USD", + CsvUrl: "http://test.csv", + PdfUrl: "http://test.pdf", + } + testInvoiceList = serverscom.InvoiceList{ + ID: testId, + Number: 123, + Status: "paid", + Date: "2025-01-01", + Type: "1", + TotalDue: 1.23, + Currency: "USD", + } +) + +func TestGetInvoiceCmd(t *testing.T) { + testCases := []struct { + name string + id string + output string + expectedOutput []byte + expectError bool + }{ + { + name: "get invoice in default format", + id: testId, + output: "", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.txt")), + }, + { + name: "get invoice in JSON format", + id: testId, + output: "json", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.json")), + }, + { + name: "get invoice in YAML format", + id: testId, + output: "yaml", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.yaml")), + }, + { + name: "get invoice with error", + id: testId, + expectError: true, + }, + } + + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + invoicesServiceHandler := mocks.NewMockInvoiceService(mockCtrl) + + scClient := serverscom.NewClientWithEndpoint("", "") + scClient.Invoices = invoicesServiceHandler + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + g := NewWithT(t) + + var err error + if tc.expectError { + err = errors.New("some error") + } + invoicesServiceHandler.EXPECT(). + GetBillingInvoice(gomock.Any(), testId). + Return(&testInvoice, err) + + testCmdContext := testutils.NewTestCmdContext(scClient) + invoiceCmd := NewCmd(testCmdContext) + + args := []string{"invoices", "get", tc.id} + if tc.output != "" { + args = append(args, "--output", tc.output) + } + + builder := testutils.NewTestCommandBuilder(). + WithCommand(invoiceCmd). + WithArgs(args) + + cmd := builder.Build() + + err = cmd.Execute() + + if tc.expectError { + g.Expect(err).To(HaveOccurred()) + } else { + g.Expect(err).To(BeNil()) + g.Expect(builder.GetOutput()).To(BeEquivalentTo(string(tc.expectedOutput))) + } + }) + } +} + +func TestListInvoicesCmd(t *testing.T) { + testInvoice1 := testInvoiceList + testInvoice2 := testInvoiceList + testInvoice1.ID += "1" + testInvoice2.Number = 456 + testInvoice2.ID += "2" + + testCases := []struct { + name string + output string + args []string + expectedOutput []byte + expectError bool + configureMock func(*mocks.MockCollection[serverscom.InvoiceList]) + }{ + { + name: "list all invoices", + output: "json", + args: []string{"-A"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_all.json")), + configureMock: func(mock *mocks.MockCollection[serverscom.InvoiceList]) { + mock.EXPECT(). + Collect(gomock.Any()). + Return([]serverscom.InvoiceList{ + testInvoice1, + testInvoice2, + }, nil) + }, + }, + { + name: "list invoices", + output: "json", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list.json")), + configureMock: func(mock *mocks.MockCollection[serverscom.InvoiceList]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.InvoiceList{ + testInvoice1, + }, nil) + }, + }, + { + name: "list invoices with template", + args: []string{"--template", "{{range .}}ID: {{.ID}}\n{{end}}"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_template.txt")), + configureMock: func(mock *mocks.MockCollection[serverscom.InvoiceList]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.InvoiceList{ + testInvoice1, + testInvoice2, + }, nil) + }, + }, + { + name: "list invoices with pageView", + args: []string{"--page-view"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_pageview.txt")), + configureMock: func(mock *mocks.MockCollection[serverscom.InvoiceList]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.InvoiceList{ + testInvoice1, + testInvoice2, + }, nil) + }, + }, + { + name: "list invoices with error", + expectError: true, + configureMock: func(mock *mocks.MockCollection[serverscom.InvoiceList]) { + mock.EXPECT(). + List(gomock.Any()). + Return(nil, errors.New("some error")) + }, + }, + } + + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + invoicesServiceHandler := mocks.NewMockInvoiceService(mockCtrl) + collectionHandler := mocks.NewMockCollection[serverscom.InvoiceList](mockCtrl) + + invoicesServiceHandler.EXPECT(). + Collection(). + Return(collectionHandler). + AnyTimes() + + collectionHandler.EXPECT(). + SetParam(gomock.Any(), gomock.Any()). + Return(collectionHandler). + AnyTimes() + + scClient := serverscom.NewClientWithEndpoint("", "") + scClient.Invoices = invoicesServiceHandler + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + g := NewWithT(t) + + if tc.configureMock != nil { + tc.configureMock(collectionHandler) + } + + testCmdContext := testutils.NewTestCmdContext(scClient) + invoiceCmd := NewCmd(testCmdContext) + + args := []string{"invoices", "list"} + if len(tc.args) > 0 { + args = append(args, tc.args...) + } + if tc.output != "" { + args = append(args, "--output", tc.output) + } + + builder := testutils.NewTestCommandBuilder(). + WithCommand(invoiceCmd). + WithArgs(args) + + cmd := builder.Build() + + err := cmd.Execute() + + if tc.expectError { + g.Expect(err).To(HaveOccurred()) + } else { + g.Expect(err).To(BeNil()) + g.Expect(builder.GetOutput()).To(BeEquivalentTo(string(tc.expectedOutput))) + } + }) + } +} diff --git a/cmd/entities/invoices/list.go b/cmd/entities/invoices/list.go new file mode 100644 index 0000000..f192ae3 --- /dev/null +++ b/cmd/entities/invoices/list.go @@ -0,0 +1,26 @@ +package invoices + +import ( + serverscom "github.com/serverscom/serverscom-go-client/pkg" + "github.com/serverscom/srvctl/cmd/base" + "github.com/spf13/cobra" +) + +func newListCmd(cmdContext *base.CmdContext) *cobra.Command { + factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.InvoiceList] { + scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient() + return scClient.Invoices.Collection() + } + + opts := base.NewListOptions( + &base.BaseListOptions[serverscom.InvoiceList]{}, + &base.StatusOption[serverscom.InvoiceList]{}, + &base.InvoiceTypeOption[serverscom.InvoiceList]{}, + &base.ParentIDOption[serverscom.InvoiceList]{}, + &base.CurrencyOption[serverscom.InvoiceList]{}, + &base.StartDateOption[serverscom.InvoiceList]{}, + &base.EndDateOption[serverscom.InvoiceList]{}, + ) + + return base.NewListCmd("list", "invoices", factory, cmdContext, opts...) +} diff --git a/cmd/entities/racks/racks_test.go b/cmd/entities/racks/racks_test.go index 0849f54..97aa442 100644 --- a/cmd/entities/racks/racks_test.go +++ b/cmd/entities/racks/racks_test.go @@ -33,25 +33,25 @@ func TestGetRackCmd(t *testing.T) { expectError bool }{ { - name: "get ssh key in default format", + name: "get rack in default format", id: testId, output: "", expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.txt")), }, { - name: "get ssh key in JSON format", + name: "get rack in JSON format", id: testId, output: "json", expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.json")), }, { - name: "get ssh key in YAML format", + name: "get rack in YAML format", id: testId, output: "yaml", expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.yaml")), }, { - name: "get ssh key with error", + name: "get rack with error", id: testId, expectError: true, }, @@ -108,7 +108,7 @@ func TestListRacksCmd(t *testing.T) { testRack2 := testRack testRack1.ID += "1" testRack2.Name = "test-rack 2" - testRack1.ID += "2" + testRack2.ID += "2" testCases := []struct { name string diff --git a/cmd/root.go b/cmd/root.go index 2dee630..a9131f0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,6 +5,7 @@ import ( "github.com/serverscom/srvctl/cmd/config" "github.com/serverscom/srvctl/cmd/context" "github.com/serverscom/srvctl/cmd/entities/hosts" + "github.com/serverscom/srvctl/cmd/entities/invoices" loadbalancers "github.com/serverscom/srvctl/cmd/entities/load_balancers" "github.com/serverscom/srvctl/cmd/entities/racks" sshkeys "github.com/serverscom/srvctl/cmd/entities/ssh-keys" @@ -44,6 +45,7 @@ func NewRootCmd(version string) *cobra.Command { cmd.AddCommand(ssl.NewCmd(cmdContext)) cmd.AddCommand(loadbalancers.NewCmd(cmdContext)) cmd.AddCommand(racks.NewCmd(cmdContext)) + cmd.AddCommand(invoices.NewCmd(cmdContext)) return cmd } diff --git a/internal/mocks/invoices_service.go b/internal/mocks/invoices_service.go new file mode 100644 index 0000000..28c432f --- /dev/null +++ b/internal/mocks/invoices_service.go @@ -0,0 +1,71 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./vendor/github.com/serverscom/serverscom-go-client/pkg/invoices.go +// +// Generated by this command: +// +// mockgen --destination ./internal/mocks/invoices_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/invoices.go +// + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + serverscom "github.com/serverscom/serverscom-go-client/pkg" + gomock "go.uber.org/mock/gomock" +) + +// MockInvoiceService is a mock of InvoiceService interface. +type MockInvoiceService struct { + ctrl *gomock.Controller + recorder *MockInvoiceServiceMockRecorder + isgomock struct{} +} + +// MockInvoiceServiceMockRecorder is the mock recorder for MockInvoiceService. +type MockInvoiceServiceMockRecorder struct { + mock *MockInvoiceService +} + +// NewMockInvoiceService creates a new mock instance. +func NewMockInvoiceService(ctrl *gomock.Controller) *MockInvoiceService { + mock := &MockInvoiceService{ctrl: ctrl} + mock.recorder = &MockInvoiceServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockInvoiceService) EXPECT() *MockInvoiceServiceMockRecorder { + return m.recorder +} + +// Collection mocks base method. +func (m *MockInvoiceService) Collection() serverscom.Collection[serverscom.InvoiceList] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Collection") + ret0, _ := ret[0].(serverscom.Collection[serverscom.InvoiceList]) + return ret0 +} + +// Collection indicates an expected call of Collection. +func (mr *MockInvoiceServiceMockRecorder) Collection() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Collection", reflect.TypeOf((*MockInvoiceService)(nil).Collection)) +} + +// GetBillingInvoice mocks base method. +func (m *MockInvoiceService) GetBillingInvoice(ctx context.Context, id string) (*serverscom.Invoice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBillingInvoice", ctx, id) + ret0, _ := ret[0].(*serverscom.Invoice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetBillingInvoice indicates an expected call of GetBillingInvoice. +func (mr *MockInvoiceServiceMockRecorder) GetBillingInvoice(ctx, id any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBillingInvoice", reflect.TypeOf((*MockInvoiceService)(nil).GetBillingInvoice), ctx, id) +} diff --git a/internal/output/entities/init.go b/internal/output/entities/init.go index d3cbd95..f7bd18e 100644 --- a/internal/output/entities/init.go +++ b/internal/output/entities/init.go @@ -16,4 +16,5 @@ func init() { RegisterSSLCertLeDefinition() RegisterLoadBalancerDefinitions() RegisterRackDefinition() + RegisterInvoiceDefinition() } diff --git a/internal/output/entities/invoices.go b/internal/output/entities/invoices.go new file mode 100644 index 0000000..a3db987 --- /dev/null +++ b/internal/output/entities/invoices.go @@ -0,0 +1,51 @@ +package entities + +import ( + "log" + "reflect" + + serverscom "github.com/serverscom/serverscom-go-client/pkg" +) + +var ( + InvoiceType = reflect.TypeOf(serverscom.Invoice{}) + InvoiceListType = reflect.TypeOf(serverscom.InvoiceList{}) +) + +func RegisterInvoiceDefinition() { + invoiceEntity := &Entity{ + fields: []Field{ + {ID: "ID", Name: "ID", Path: "ID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Number", Name: "Number", Path: "Number", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "ParentID", Name: "ParentID", Path: "ParentID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Status", Name: "Status", Path: "Status", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Date", Name: "Date", Path: "Date", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Type", Name: "Type", Path: "Type", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "TotalDue", Name: "TotalDue", Path: "TotalDue", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Currency", Name: "Currency", Path: "Currency", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "CsvUrl", Name: "CsvUrl", Path: "CsvUrl", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "PdfUrl", Name: "PdfUrl", Path: "PdfUrl", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + }, + eType: InvoiceType, + } + if err := Registry.Register(invoiceEntity); err != nil { + log.Fatal(err) + } + + invoiceListEntity := &Entity{ + fields: []Field{ + {ID: "ID", Name: "ID", Path: "ID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Number", Name: "Number", Path: "Number", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "ParentID", Name: "ParentID", Path: "ParentID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Status", Name: "Status", Path: "Status", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Date", Name: "Date", Path: "Date", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Type", Name: "Type", Path: "Type", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "TotalDue", Name: "TotalDue", Path: "TotalDue", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Currency", Name: "Currency", Path: "Currency", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + }, + eType: InvoiceListType, + } + if err := Registry.Register(invoiceListEntity); err != nil { + log.Fatal(err) + } +} diff --git a/testdata/entities/invoices/get.json b/testdata/entities/invoices/get.json new file mode 100644 index 0000000..755a9e5 --- /dev/null +++ b/testdata/entities/invoices/get.json @@ -0,0 +1,12 @@ +{ + "id": "testId", + "number": 123, + "parent_id": null, + "status": "paid", + "date": "2025-01-01", + "type": "1", + "total_due": 1.23, + "currency": "USD", + "csv_url": "http://test.csv", + "pdf_url": "http://test.pdf" +} \ No newline at end of file diff --git a/testdata/entities/invoices/get.txt b/testdata/entities/invoices/get.txt new file mode 100644 index 0000000..f3f3be4 --- /dev/null +++ b/testdata/entities/invoices/get.txt @@ -0,0 +1,2 @@ +ID Number ParentID Status Date Type TotalDue Currency +testId 123 paid 2025-01-01 1 1.23 USD diff --git a/testdata/entities/invoices/get.yaml b/testdata/entities/invoices/get.yaml new file mode 100644 index 0000000..c035dac --- /dev/null +++ b/testdata/entities/invoices/get.yaml @@ -0,0 +1,10 @@ +id: testId +number: 123 +parentid: null +status: paid +date: "2025-01-01" +type: "1" +totaldue: 1.23 +currency: USD +csvurl: http://test.csv +pdfurl: http://test.pdf diff --git a/testdata/entities/invoices/list.json b/testdata/entities/invoices/list.json new file mode 100644 index 0000000..19d57ce --- /dev/null +++ b/testdata/entities/invoices/list.json @@ -0,0 +1,12 @@ +[ + { + "id": "testId1", + "number": 123, + "parent_id": null, + "status": "paid", + "date": "2025-01-01", + "type": "1", + "total_due": 1.23, + "currency": "USD" + } +] \ No newline at end of file diff --git a/testdata/entities/invoices/list_all.json b/testdata/entities/invoices/list_all.json new file mode 100644 index 0000000..b663de9 --- /dev/null +++ b/testdata/entities/invoices/list_all.json @@ -0,0 +1,22 @@ +[ + { + "id": "testId1", + "number": 123, + "parent_id": null, + "status": "paid", + "date": "2025-01-01", + "type": "1", + "total_due": 1.23, + "currency": "USD" + }, + { + "id": "testId2", + "number": 456, + "parent_id": null, + "status": "paid", + "date": "2025-01-01", + "type": "1", + "total_due": 1.23, + "currency": "USD" + } +] \ No newline at end of file diff --git a/testdata/entities/invoices/list_pageview.txt b/testdata/entities/invoices/list_pageview.txt new file mode 100644 index 0000000..ba7408b --- /dev/null +++ b/testdata/entities/invoices/list_pageview.txt @@ -0,0 +1,17 @@ +ID: testId1 +Number: 123 +ParentID: +Status: paid +Date: 2025-01-01 +Type: 1 +TotalDue: 1.23 +Currency: USD +--- +ID: testId2 +Number: 456 +ParentID: +Status: paid +Date: 2025-01-01 +Type: 1 +TotalDue: 1.23 +Currency: USD diff --git a/testdata/entities/invoices/list_template.txt b/testdata/entities/invoices/list_template.txt new file mode 100644 index 0000000..c4fe76e --- /dev/null +++ b/testdata/entities/invoices/list_template.txt @@ -0,0 +1,2 @@ +ID: testId1 +ID: testId2 diff --git a/testdata/entities/racks/list.json b/testdata/entities/racks/list.json index f05963c..a1a9498 100644 --- a/testdata/entities/racks/list.json +++ b/testdata/entities/racks/list.json @@ -1,6 +1,6 @@ [ { - "id": "testId12", + "id": "testId1", "name": "test-rack", "location_id": 1, "location_code": "test", diff --git a/testdata/entities/racks/list_all.json b/testdata/entities/racks/list_all.json index 1ba13b2..282c5e2 100644 --- a/testdata/entities/racks/list_all.json +++ b/testdata/entities/racks/list_all.json @@ -1,6 +1,6 @@ [ { - "id": "testId12", + "id": "testId1", "name": "test-rack", "location_id": 1, "location_code": "test", @@ -9,7 +9,7 @@ } }, { - "id": "testId", + "id": "testId2", "name": "test-rack 2", "location_id": 1, "location_code": "test", diff --git a/testdata/entities/racks/list_pageview.txt b/testdata/entities/racks/list_pageview.txt index 2e8a3c4..4bcc794 100644 --- a/testdata/entities/racks/list_pageview.txt +++ b/testdata/entities/racks/list_pageview.txt @@ -1,10 +1,10 @@ -ID: testId12 +ID: testId1 Name: test-rack LocationID: 1 LocationCode: test Labels: foo=bar --- -ID: testId +ID: testId2 Name: test-rack 2 LocationID: 1 LocationCode: test