MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestDestinationOrDestinationsValidation

Function TestDestinationOrDestinationsValidation

api/model/model_test.go:51–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestDestinationOrDestinationsValidation(t *testing.T) {
52 tests := []struct {
53 name string
54 transaction RecordTransaction
55 wantErr bool
56 }{
57 {
58 name: "Valid with Destination",
59 transaction: RecordTransaction{Destination: "dest1"},
60 wantErr: false,
61 },
62 {
63 name: "Valid with Destinations",
64 transaction: RecordTransaction{Destinations: []model.Distribution{{Identifier: "dest1", Distribution: "100"}}},
65 wantErr: false,
66 },
67 {
68 name: "Invalid with both Destination and Destinations",
69 transaction: RecordTransaction{Destination: "dest1", Destinations: []model.Distribution{{Identifier: "dest2", Distribution: "100"}}},
70 wantErr: true,
71 },
72 {
73 name: "Invalid with neither Destination nor Destinations",
74 transaction: RecordTransaction{},
75 wantErr: true,
76 },
77 }
78
79 for _, tt := range tests {
80 t.Run(tt.name, func(t *testing.T) {
81 err := destinationOrDestinationsValidation(&tt.transaction)(nil)
82 if tt.wantErr {
83 assert.Error(t, err)
84 } else {
85 assert.NoError(t, err)
86 }
87 })
88 }
89}
90
91func TestValidateCreateLedger(t *testing.T) {
92 tests := []struct {

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected