File tree 1 file changed +41
-0
lines changed 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,47 @@ func fakePackage() *packages.Package {
44
44
}
45
45
}
46
46
47
+ type Foo struct {
48
+ Value string
49
+ }
50
+
51
+ func TestCache_Put (t * testing.T ) {
52
+ t .Setenv ("GOLANGCI_LINT_CACHE" , t .TempDir ())
53
+
54
+ pkgCache := setupCache (t )
55
+
56
+ pkg := fakePackage ()
57
+
58
+ in := & Foo {Value : "hello" }
59
+
60
+ err := pkgCache .Put (pkg , HashModeNeedAllDeps , "key" , in )
61
+ require .NoError (t , err )
62
+
63
+ out := & Foo {}
64
+ err = pkgCache .Get (pkg , HashModeNeedAllDeps , "key" , out )
65
+ require .NoError (t , err )
66
+
67
+ assert .Equal (t , in , out )
68
+
69
+ pkgCache .Close ()
70
+ }
71
+
72
+ func TestCache_Get_missing_data (t * testing.T ) {
73
+ t .Setenv ("GOLANGCI_LINT_CACHE" , t .TempDir ())
74
+
75
+ pkgCache := setupCache (t )
76
+
77
+ pkg := fakePackage ()
78
+
79
+ out := & Foo {}
80
+ err := pkgCache .Get (pkg , HashModeNeedAllDeps , "key" , out )
81
+ require .Error (t , err )
82
+
83
+ require .ErrorIs (t , err , ErrMissing )
84
+
85
+ pkgCache .Close ()
86
+ }
87
+
47
88
func TestCache_buildKey (t * testing.T ) {
48
89
pkgCache := setupCache (t )
49
90
You can’t perform that action at this time.
0 commit comments