github.com/condensat/bank-core@v0.1.0/database/model/assetinfo_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 "testing" 8 9 func TestAssetInfo_Valid(t *testing.T) { 10 type fields struct { 11 AssetID AssetID 12 Domain string 13 Name string 14 Ticker string 15 Precision uint8 16 } 17 tests := []struct { 18 name string 19 fields fields 20 want bool 21 }{ 22 {"default", fields{}, false}, 23 {"invalidDomain", fields{42, "", "FooBar", "FBAR", 0}, false}, 24 {"invalidName", fields{42, "foo.bar", "", "FBAR", 0}, false}, 25 {"invalidTicker", fields{42, "foo.bar", "FooBar", "", 0}, false}, 26 {"invalidTicker", fields{42, "foo.bar", "FooBar", "F00BAR", 0}, false}, 27 28 {"valid", fields{42, "foo.bar", "FooBar", "FBAR", 0}, true}, 29 } 30 for _, tt := range tests { 31 t.Run(tt.name, func(t *testing.T) { 32 p := &AssetInfo{ 33 AssetID: tt.fields.AssetID, 34 Domain: tt.fields.Domain, 35 Name: tt.fields.Name, 36 Ticker: tt.fields.Ticker, 37 Precision: tt.fields.Precision, 38 } 39 if got := p.Valid(); got != tt.want { 40 t.Errorf("AssetInfo.Valid() = %v, want %v", got, tt.want) 41 } 42 }) 43 } 44 }