github.com/condensat/bank-core@v0.1.0/database/model/batchinfo_test.go (about) 1 // Copyright 2020 Condensat Tech. All rights reserved. 2 // Use of this source code is governed by a MIT 3 // license that can be found in the LICENSE file. 4 5 package model 6 7 import ( 8 "reflect" 9 "testing" 10 "time" 11 12 "github.com/condensat/bank-core/database/encoding" 13 ) 14 15 func TestBatchInfo_CryptoData(t *testing.T) { 16 t.Parallel() 17 18 type fields struct { 19 ID BatchInfoID 20 Timestamp time.Time 21 BatchID BatchID 22 Status BatchStatus 23 Type encoding.DataType 24 Data BatchInfoData 25 } 26 tests := []struct { 27 name string 28 fields fields 29 want BatchInfoCryptoData 30 wantErr bool 31 }{ 32 {"default", fields{}, BatchInfoCryptoData{}, true}, 33 {"type", fields{Type: BatchInfoCrypto}, BatchInfoCryptoData{}, false}, 34 } 35 for _, tt := range tests { 36 tt := tt // capture range variable 37 t.Run(tt.name, func(t *testing.T) { 38 p := &BatchInfo{ 39 ID: tt.fields.ID, 40 Timestamp: tt.fields.Timestamp, 41 BatchID: tt.fields.BatchID, 42 Status: tt.fields.Status, 43 Type: tt.fields.Type, 44 Data: tt.fields.Data, 45 } 46 got, err := p.CryptoData() 47 if (err != nil) != tt.wantErr { 48 t.Errorf("BatchInfo.CryptoData() error = %v, wantErr %v", err, tt.wantErr) 49 return 50 } 51 if !reflect.DeepEqual(got, tt.want) { 52 t.Errorf("BatchInfo.CryptoData() = %v, want %v", got, tt.want) 53 } 54 }) 55 } 56 }