File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,47 @@ func fakePackage() *packages.Package {
4444 }
4545}
4646
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+
4788func TestCache_buildKey (t * testing.T ) {
4889 pkgCache := setupCache (t )
4990
Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ func DefaultDir() (string, bool) {
8080
8181 defaultDirOnce .Do (func () {
8282 defaultDir = os .Getenv (envGolangciLintCache )
83+ println (envGolangciLintCache , defaultDir )
84+
8385 if defaultDir != "" {
8486 defaultDirChanged = true
8587 if filepath .IsAbs (defaultDir ) || defaultDir == "off" {
You can’t perform that action at this time.
0 commit comments