-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathasset_test.go
85 lines (75 loc) · 1.62 KB
/
asset_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0
package open_asset_model
import (
"testing"
)
type MockAsset struct {
assetType AssetType
}
func (a MockAsset) AssetType() AssetType {
return a.assetType
}
func TestAssetInterface(t *testing.T) {
mockAsset := MockAsset{assetType: IPAddress}
if mockAsset.AssetType() != IPAddress {
t.Error("AssetType() does not return the expected value")
}
}
func TestAssetTypeConstants(t *testing.T) {
assetTypes := []AssetType{
Account,
AutnumRecord,
AutonomousSystem,
ContactRecord,
DomainRecord,
File,
FQDN,
FundsTransfer,
Identifier,
IPAddress,
IPNetRecord,
Location,
Netblock,
Organization,
Person,
Phone,
Product,
ProductRelease,
Service,
TLSCertificate,
URL,
}
expectedTypes := []string{
"Account",
"AutnumRecord",
"AutonomousSystem",
"ContactRecord",
"DomainRecord",
"File",
"FQDN",
"FundsTransfer",
"Identifier",
"IPAddress",
"IPNetRecord",
"Location",
"Netblock",
"Organization",
"Person",
"Phone",
"Product",
"ProductRelease",
"Service",
"TLSCertificate",
"URL",
}
if len(assetTypes) != len(expectedTypes) {
t.Error("Number of asset types does not match the expected number")
}
for i, assetType := range assetTypes {
if string(assetType) != expectedTypes[i] {
t.Errorf("Asset type %s does not match the expected value %s", assetType, expectedTypes[i])
}
}
}