forked from stack11/go-exactonline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
682 lines (636 loc) · 22.3 KB
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
// Copyright 2018 The go-exactonline AUTHORS. All rights reserved.
//
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package exactonline
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"testing"
"time"
"github.com/gofrs/uuid"
"github.com/stack11/go-exactonline/api"
"github.com/stack11/go-exactonline/services/accountancy"
"github.com/stack11/go-exactonline/services/activities"
"github.com/stack11/go-exactonline/services/assets"
"github.com/stack11/go-exactonline/services/budget"
"github.com/stack11/go-exactonline/services/bulk"
"github.com/stack11/go-exactonline/services/cashflow"
"github.com/stack11/go-exactonline/services/continuousmonitoring"
"github.com/stack11/go-exactonline/services/crm"
"github.com/stack11/go-exactonline/services/documents"
"github.com/stack11/go-exactonline/services/financial"
"github.com/stack11/go-exactonline/services/financialtransaction"
"github.com/stack11/go-exactonline/services/general"
"github.com/stack11/go-exactonline/services/generaljournalentry"
"github.com/stack11/go-exactonline/services/hrm"
"github.com/stack11/go-exactonline/services/inventory"
"github.com/stack11/go-exactonline/services/logistics"
"github.com/stack11/go-exactonline/services/mailbox"
"github.com/stack11/go-exactonline/services/manufacturing"
"github.com/stack11/go-exactonline/services/openingbalance"
"github.com/stack11/go-exactonline/services/payroll"
"github.com/stack11/go-exactonline/services/project"
"github.com/stack11/go-exactonline/services/purchase"
"github.com/stack11/go-exactonline/services/purchaseentry"
"github.com/stack11/go-exactonline/services/purchaseorder"
"github.com/stack11/go-exactonline/services/sales"
"github.com/stack11/go-exactonline/services/salesentry"
"github.com/stack11/go-exactonline/services/salesinvoice"
"github.com/stack11/go-exactonline/services/salesorder"
"github.com/stack11/go-exactonline/services/subscription"
"github.com/stack11/go-exactonline/services/system"
"github.com/stack11/go-exactonline/services/users"
"github.com/stack11/go-exactonline/services/vat"
"github.com/stack11/go-exactonline/services/webhooks"
"github.com/stack11/go-exactonline/services/workflow"
"github.com/stack11/go-exactonline/types"
"golang.org/x/oauth2"
)
// setup sets up a test HTTP server along with a exactonline.Client that is
// configured to talk to that test server. Tests should register handlers on
// mux which provide mock responses for the API method being tested.
func setup() (client *Client, mux *http.ServeMux, serverURL string, teardown func()) {
// mux is the HTTP request multiplexer used with the test server.
mux = http.NewServeMux()
// We want to ensure that tests catch mistakes where the endpoint URL is
// specified as absolute rather than relative. It only makes a difference
// when there's a non-empty base URL path. So, use that. See issue #752.
apiHandler := http.NewServeMux()
apiHandler.Handle("/", mux)
// server is a test HTTP server used to provide mock API responses.
server := httptest.NewServer(apiHandler)
// client is the GitHub client being tested and is
// configured to use test server.
client = NewClient(nil)
client.SetBaseURL(server.URL + "/")
return client, mux, server.URL, server.Close
}
func TestNewClient(t *testing.T) {
type args struct {
httpClient *http.Client
}
a := api.NewClient(nil)
b := &http.Client{Timeout: 1 * time.Millisecond}
c := api.NewClient(b)
tests := []struct {
name string
args args
want *Client
}{
{"default", args{http.DefaultClient}, &Client{
client: api.NewClient(nil),
HRM: hrm.NewHRMService(a),
VAT: vat.NewVATService(a),
Webhooks: webhooks.NewWebhooksService(a),
Activities: activities.NewActivitiesService(a),
Documents: documents.NewDocumentsService(a),
Payroll: payroll.NewPayrollService(a),
Bulk: bulk.NewBulkService(a),
FinancialTransaction: financialtransaction.NewFinancialTransactionService(a),
GeneralJournalEntry: generaljournalentry.NewGeneralJournalEntryService(a),
Manufacturing: manufacturing.NewManufacturingService(a),
Workflow: workflow.NewWorkflowService(a),
ContinuousMonitoring: continuousmonitoring.NewContinuousMonitoringService(a),
Financial: financial.NewFinancialService(a),
OpeningBalance: openingbalance.NewOpeningBalanceService(a),
Project: project.NewProjectService(a),
PurchaseEntry: purchaseentry.NewPurchaseEntryService(a),
PurchaseOrder: purchaseorder.NewPurchaseOrderService(a),
Subscription: subscription.NewSubscriptionService(a),
Cashflow: cashflow.NewCashflowService(a),
Mailbox: mailbox.NewMailboxService(a),
Purchase: purchase.NewPurchaseService(a),
Sales: sales.NewSalesService(a),
System: system.NewSystemService(a),
CRM: crm.NewCRMService(a),
Logistics: logistics.NewLogisticsService(a),
General: general.NewGeneralService(a),
SalesInvoice: salesinvoice.NewSalesInvoiceService(a),
SalesOrder: salesorder.NewSalesOrderService(a),
Users: users.NewUsersService(a),
Inventory: inventory.NewInventoryService(a),
SalesEntry: salesentry.NewSalesEntryService(a),
Budget: budget.NewBudgetService(a),
Accountancy: accountancy.NewAccountancyService(a),
Assets: assets.NewAssetsService(a),
}},
{"custom", args{b}, &Client{
client: api.NewClient(b),
HRM: hrm.NewHRMService(c),
VAT: vat.NewVATService(c),
Webhooks: webhooks.NewWebhooksService(c),
Activities: activities.NewActivitiesService(c),
Documents: documents.NewDocumentsService(c),
Payroll: payroll.NewPayrollService(c),
Bulk: bulk.NewBulkService(c),
FinancialTransaction: financialtransaction.NewFinancialTransactionService(c),
GeneralJournalEntry: generaljournalentry.NewGeneralJournalEntryService(c),
Manufacturing: manufacturing.NewManufacturingService(c),
Workflow: workflow.NewWorkflowService(c),
ContinuousMonitoring: continuousmonitoring.NewContinuousMonitoringService(c),
Financial: financial.NewFinancialService(c),
OpeningBalance: openingbalance.NewOpeningBalanceService(c),
Project: project.NewProjectService(c),
PurchaseEntry: purchaseentry.NewPurchaseEntryService(c),
PurchaseOrder: purchaseorder.NewPurchaseOrderService(c),
Subscription: subscription.NewSubscriptionService(c),
Cashflow: cashflow.NewCashflowService(c),
Mailbox: mailbox.NewMailboxService(c),
Purchase: purchase.NewPurchaseService(c),
Sales: sales.NewSalesService(c),
System: system.NewSystemService(c),
CRM: crm.NewCRMService(c),
Logistics: logistics.NewLogisticsService(c),
General: general.NewGeneralService(c),
SalesInvoice: salesinvoice.NewSalesInvoiceService(c),
SalesOrder: salesorder.NewSalesOrderService(c),
Users: users.NewUsersService(c),
Inventory: inventory.NewInventoryService(c),
SalesEntry: salesentry.NewSalesEntryService(c),
Budget: budget.NewBudgetService(c),
Accountancy: accountancy.NewAccountancyService(c),
Assets: assets.NewAssetsService(c),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewClient(tt.args.httpClient); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewClient() = %v, want %v", got, tt.want)
}
})
}
}
func TestNewClientFromTokenSource(t *testing.T) {
type args struct {
ctx context.Context
tokenSource oauth2.TokenSource
}
ctx := context.Background()
tok := oauth2.StaticTokenSource(&oauth2.Token{})
c := oauth2.NewClient(ctx, tok)
tests := []struct {
name string
args args
want *Client
}{
{"1", args{ctx, tok}, NewClient(c)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewClientFromTokenSource(tt.args.ctx, tt.args.tokenSource); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewClientFromTokenSource() = %v, want %v", got, tt.want)
}
})
}
}
func TestClient_SetBaseURL(t *testing.T) {
type fields struct {
client *api.Client
Budget *budget.BudgetService
Bulk *bulk.BulkService
ContinuousMonitoring *continuousmonitoring.ContinuousMonitoringService
Documents *documents.DocumentsService
FinancialTransaction *financialtransaction.FinancialTransactionService
General *general.GeneralService
Inventory *inventory.InventoryService
Accountancy *accountancy.AccountancyService
Users *users.UsersService
VAT *vat.VATService
Workflow *workflow.WorkflowService
PurchaseEntry *purchaseentry.PurchaseEntryService
Payroll *payroll.PayrollService
Purchase *purchase.PurchaseService
SalesOrder *salesorder.SalesOrderService
Logistics *logistics.LogisticsService
CRM *crm.CRMService
GeneralJournalEntry *generaljournalentry.GeneralJournalEntryService
OpeningBalance *openingbalance.OpeningBalanceService
Project *project.ProjectService
Webhooks *webhooks.WebhooksService
Cashflow *cashflow.CashflowService
SalesInvoice *salesinvoice.SalesInvoiceService
PurchaseOrder *purchaseorder.PurchaseOrderService
Sales *sales.SalesService
SalesEntry *salesentry.SalesEntryService
Mailbox *mailbox.MailboxService
Assets *assets.AssetsService
Financial *financial.FinancialService
HRM *hrm.HRMService
Manufacturing *manufacturing.ManufacturingService
Subscription *subscription.SubscriptionService
System *system.SystemService
Activities *activities.ActivitiesService
}
type args struct {
baseURL string
u *url.URL
}
c := api.NewClient(nil)
uri := "https://start.exactonline.nl/"
u, _ := url.Parse(uri)
uri2 := "https://start.exactonline.nl"
u2, _ := url.Parse(uri2)
uri3 := ":foo"
u3, _ := url.Parse(uri2)
tests := []struct {
name string
fields fields
args args
wantErr bool
wantEqual bool
}{
{"1", fields{client: c}, args{uri, u}, false, true},
{"2", fields{client: c}, args{uri2, u2}, false, false},
{"3", fields{client: c}, args{uri3, u3}, true, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Client{
client: tt.fields.client,
Budget: tt.fields.Budget,
Bulk: tt.fields.Bulk,
ContinuousMonitoring: tt.fields.ContinuousMonitoring,
Documents: tt.fields.Documents,
FinancialTransaction: tt.fields.FinancialTransaction,
General: tt.fields.General,
Inventory: tt.fields.Inventory,
Accountancy: tt.fields.Accountancy,
Users: tt.fields.Users,
VAT: tt.fields.VAT,
Workflow: tt.fields.Workflow,
PurchaseEntry: tt.fields.PurchaseEntry,
Payroll: tt.fields.Payroll,
Purchase: tt.fields.Purchase,
SalesOrder: tt.fields.SalesOrder,
Logistics: tt.fields.Logistics,
CRM: tt.fields.CRM,
GeneralJournalEntry: tt.fields.GeneralJournalEntry,
OpeningBalance: tt.fields.OpeningBalance,
Project: tt.fields.Project,
Webhooks: tt.fields.Webhooks,
Cashflow: tt.fields.Cashflow,
SalesInvoice: tt.fields.SalesInvoice,
PurchaseOrder: tt.fields.PurchaseOrder,
Sales: tt.fields.Sales,
SalesEntry: tt.fields.SalesEntry,
Mailbox: tt.fields.Mailbox,
Assets: tt.fields.Assets,
Financial: tt.fields.Financial,
HRM: tt.fields.HRM,
Manufacturing: tt.fields.Manufacturing,
Subscription: tt.fields.Subscription,
System: tt.fields.System,
Activities: tt.fields.Activities,
}
if err := c.SetBaseURL(tt.args.baseURL); (err != nil) != tt.wantErr {
t.Errorf("Client.SetBaseURL() error = %v, wantErr %v", err, tt.wantErr)
}
if got, want := c.client.BaseURL, tt.args.u; reflect.DeepEqual(got, want) != tt.wantEqual {
t.Errorf("Client.SetBaseURL() got = %v, want %v", got, want)
}
})
}
}
func TestClient_SetUserAgent(t *testing.T) {
type fields struct {
client *api.Client
Budget *budget.BudgetService
Bulk *bulk.BulkService
ContinuousMonitoring *continuousmonitoring.ContinuousMonitoringService
Documents *documents.DocumentsService
FinancialTransaction *financialtransaction.FinancialTransactionService
General *general.GeneralService
Inventory *inventory.InventoryService
Accountancy *accountancy.AccountancyService
Users *users.UsersService
VAT *vat.VATService
Workflow *workflow.WorkflowService
PurchaseEntry *purchaseentry.PurchaseEntryService
Payroll *payroll.PayrollService
Purchase *purchase.PurchaseService
SalesOrder *salesorder.SalesOrderService
Logistics *logistics.LogisticsService
CRM *crm.CRMService
GeneralJournalEntry *generaljournalentry.GeneralJournalEntryService
OpeningBalance *openingbalance.OpeningBalanceService
Project *project.ProjectService
Webhooks *webhooks.WebhooksService
Cashflow *cashflow.CashflowService
SalesInvoice *salesinvoice.SalesInvoiceService
PurchaseOrder *purchaseorder.PurchaseOrderService
Sales *sales.SalesService
SalesEntry *salesentry.SalesEntryService
Mailbox *mailbox.MailboxService
Assets *assets.AssetsService
Financial *financial.FinancialService
HRM *hrm.HRMService
Manufacturing *manufacturing.ManufacturingService
Subscription *subscription.SubscriptionService
System *system.SystemService
Activities *activities.ActivitiesService
}
type args struct {
userAgent string
}
c := api.NewClient(nil)
tests := []struct {
name string
fields fields
args args
}{
{"1", fields{client: c}, args{"test user agent"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Client{
client: tt.fields.client,
Budget: tt.fields.Budget,
Bulk: tt.fields.Bulk,
ContinuousMonitoring: tt.fields.ContinuousMonitoring,
Documents: tt.fields.Documents,
FinancialTransaction: tt.fields.FinancialTransaction,
General: tt.fields.General,
Inventory: tt.fields.Inventory,
Accountancy: tt.fields.Accountancy,
Users: tt.fields.Users,
VAT: tt.fields.VAT,
Workflow: tt.fields.Workflow,
PurchaseEntry: tt.fields.PurchaseEntry,
Payroll: tt.fields.Payroll,
Purchase: tt.fields.Purchase,
SalesOrder: tt.fields.SalesOrder,
Logistics: tt.fields.Logistics,
CRM: tt.fields.CRM,
GeneralJournalEntry: tt.fields.GeneralJournalEntry,
OpeningBalance: tt.fields.OpeningBalance,
Project: tt.fields.Project,
Webhooks: tt.fields.Webhooks,
Cashflow: tt.fields.Cashflow,
SalesInvoice: tt.fields.SalesInvoice,
PurchaseOrder: tt.fields.PurchaseOrder,
Sales: tt.fields.Sales,
SalesEntry: tt.fields.SalesEntry,
Mailbox: tt.fields.Mailbox,
Assets: tt.fields.Assets,
Financial: tt.fields.Financial,
HRM: tt.fields.HRM,
Manufacturing: tt.fields.Manufacturing,
Subscription: tt.fields.Subscription,
System: tt.fields.System,
Activities: tt.fields.Activities,
}
c.SetUserAgent(tt.args.userAgent)
if got, want := c.client.UserAgent, tt.args.userAgent; got != want {
t.Errorf("Client.SetUserAgent(%v) = %v, want %v", tt.args.userAgent, got, want)
}
})
}
}
func testMethod(t *testing.T, r *http.Request, want string) {
if got := r.Method; got != want {
t.Errorf("Request method: %v, want %v", got, want)
}
}
func TestClient_GetCurrentDivisionID(t *testing.T) {
c, mux, _, teardown := setup()
defer teardown()
want := 100
mux.HandleFunc("/api/v1/current/Me", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{ "d": { "__next": "", "results": [{ "CurrentDivision": 100 }]}}`)
})
ctx := context.Background()
got, err := c.GetCurrentDivisionID(ctx)
if err != nil {
t.Errorf("Client.GetCurrentDivisionID() error = %v", err)
}
if got != want {
t.Errorf("Client.GetCurrentDivisionID() = %v, want %v", got, want)
}
}
func TestClient_GetCurrentDivisionID_error_count(t *testing.T) {
c, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/api/v1/current/Me", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{ "d": { "__next": "", "results": [{ "CurrentDivision": 100 }, { "CurrentDivision": 200 }]}}`)
})
ctx := context.Background()
_, err := c.GetCurrentDivisionID(ctx)
if err == nil {
t.Error("Client.GetCurrentDivisionID() want error but got nil")
}
}
func TestClient_GetCurrentDivisionID_error(t *testing.T) {
c, _, _, teardown := setup()
defer teardown()
ctx := context.Background()
_, err := c.GetCurrentDivisionID(ctx)
if err == nil {
t.Error("Client.GetCurrentDivisionID() want error but got nil")
}
}
func TestClient_GetMe(t *testing.T) {
c, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/api/v1/current/Me", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{ "d": { "__next": "", "results": [{ "CurrentDivision": 100 }]}}`)
})
ctx := context.Background()
got, err := c.GetMe(ctx)
if err != nil {
t.Errorf("Client.GetMe() error = %v", err)
}
want := &system.Me{CurrentDivision: Int(100)}
if !reflect.DeepEqual(got, want) {
t.Errorf("Client.GetMe() = %v, want %v", got, want)
}
}
func TestClient_GetMe_error(t *testing.T) {
c, _, _, teardown := setup()
defer teardown()
ctx := context.Background()
_, err := c.GetMe(ctx)
if err == nil {
t.Error("Client.GetMe() want error but got nil")
}
}
func TestClient_GetMe_error_count(t *testing.T) {
c, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/api/v1/current/Me", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{ "d": { "__next": "", "results": [{ "CurrentDivision": 100 }, { "CurrentDivision": 200 }]}}`)
})
ctx := context.Background()
_, err := c.GetMe(ctx)
if err == nil {
t.Error("Client.GetMe() want error but got nil")
}
}
func TestBool(t *testing.T) {
type args struct {
v bool
}
b := true
tests := []struct {
name string
args args
want *bool
}{
{"1", args{b}, &b},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Bool(tt.args.v); *got != *tt.want {
t.Errorf("Bool() = %v, want %v", got, tt.want)
}
})
}
}
func TestInt(t *testing.T) {
type args struct {
v int
}
i := 1000
tests := []struct {
name string
args args
want *int
}{
{"1", args{i}, &i},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Int(tt.args.v); *got != *tt.want {
t.Errorf("Int() = %v, want %v", got, tt.want)
}
})
}
}
func TestInt64(t *testing.T) {
type args struct {
v int64
}
i := int64(1000)
tests := []struct {
name string
args args
want *int64
}{
{"1", args{i}, &i},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Int64(tt.args.v); *got != *tt.want {
t.Errorf("Int64() = %v, want %v", got, tt.want)
}
})
}
}
func TestString(t *testing.T) {
type args struct {
v string
}
s := "teststring"
tests := []struct {
name string
args args
want *string
}{
{"1", args{s}, &s},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := String(tt.args.v); *got != *tt.want {
t.Errorf("String() = %v, want %v", got, tt.want)
}
})
}
}
func TestDate(t *testing.T) {
type args struct {
v time.Time
}
d := time.Now()
tests := []struct {
name string
args args
want *types.Date
}{
{"1", args{d}, &types.Date{Time: d}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Date(tt.args.v); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Date() = %v, want %v", got, tt.want)
}
})
}
}
func TestFloat64(t *testing.T) {
type args struct {
v float64
}
f := float64(10.12)
tests := []struct {
name string
args args
want *float64
}{
{"1", args{f}, &f},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Float64(tt.args.v); *got != *tt.want {
t.Errorf("Float64() = %v, want %v", got, tt.want)
}
})
}
}
func TestGUID(t *testing.T) {
type args struct {
v uuid.UUID
}
u := uuid.Must(uuid.NewV4())
tests := []struct {
name string
args args
want *types.GUID
}{
{"1", args{u}, &types.GUID{UUID: u}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GUID(tt.args.v); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GUID() = %v, want %v", got, tt.want)
}
})
}
}
func TestURL(t *testing.T) {
type args struct {
v *url.URL
}
u, _ := url.Parse("https://start.exactonline.nl")
tests := []struct {
name string
args args
want *types.URL
}{
{"1", args{u}, &types.URL{URL: u}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := URL(tt.args.v); !reflect.DeepEqual(got, tt.want) {
t.Errorf("URL() = %v, want %v", got, tt.want)
}
})
}
}