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

Function TestSourceOrSourcesValidation

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

Source from the content-addressed store, hash-verified

9)
10
11func TestSourceOrSourcesValidation(t *testing.T) {
12 tests := []struct {
13 name string
14 transaction RecordTransaction
15 wantErr bool
16 }{
17 {
18 name: "Valid with Source",
19 transaction: RecordTransaction{Source: "source1"},
20 wantErr: false,
21 },
22 {
23 name: "Valid with Sources",
24 transaction: RecordTransaction{Sources: []model.Distribution{{Identifier: "source1", Distribution: "100"}}},
25 wantErr: false,
26 },
27 {
28 name: "Invalid with both Source and Sources",
29 transaction: RecordTransaction{Source: "source1", Sources: []model.Distribution{{Identifier: "source2", Distribution: "100"}}},
30 wantErr: true,
31 },
32 {
33 name: "Invalid with neither Source nor Sources",
34 transaction: RecordTransaction{},
35 wantErr: true,
36 },
37 }
38
39 for _, tt := range tests {
40 t.Run(tt.name, func(t *testing.T) {
41 err := sourceOrSourcesValidation(&tt.transaction)(nil)
42 if tt.wantErr {
43 assert.Error(t, err)
44 } else {
45 assert.NoError(t, err)
46 }
47 })
48 }
49}
50
51func TestDestinationOrDestinationsValidation(t *testing.T) {
52 tests := []struct {

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected