(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func 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 | |
| 91 | func TestValidateCreateLedger(t *testing.T) { |
| 92 | tests := []struct { |
nothing calls this directly
no test coverage detected