forked from kai-ten/go-csf-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_test.go
65 lines (55 loc) · 1.16 KB
/
file_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
package gcs
import (
"testing"
"time"
)
func TestValidFileObject(t *testing.T) {
// contains many more optional fields
file := &File{
Name: "name",
TypeID: UInteger8(0),
}
_, err := ValidateFile(file)
if err != nil {
t.Fatalf("File should have been valid: %v", err)
}
}
func TestInvalidNameFileObject(t *testing.T) {
time := time.Now()
// contains many more optional fields
file := &File{
AccessedTime: &time,
Name: "",
TypeID: UInteger8(1),
}
_, err := ValidateFile(file)
if err == nil {
t.Fatalf("File Name should have been invalid: %v", err)
}
}
func TestInvalidTypeIDFileObject(t *testing.T) {
time := time.Now()
// contains many more optional fields
file := &File{
AccessedTime: &time,
Name: "name",
}
_, err := ValidateFile(file)
if err == nil {
t.Fatalf("File TypeID should have been invalid: %v", err)
}
}
func BenchmarkValidFileObject(b *testing.B) {
b.ReportAllocs()
// contains many more optional fields
file := &File{
Name: "name",
TypeID: UInteger8(2),
}
for n := 0; n < b.N; n++ {
_, err := ValidateFile(file)
if err != nil {
b.Fatalf("File object is invalid: %v", err)
}
}
}