mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
chore: add mocked cache
This commit is contained in:
parent
7738cad7cb
commit
e846f2b683
|
@ -102,10 +102,8 @@ func (c *commandCache) get(command string) (string, bool) {
|
||||||
if !found {
|
if !found {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
if command, ok := cmd.(string); ok {
|
command, ok := cmd.(string)
|
||||||
return command, true
|
return command, ok
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type tracer struct {
|
type tracer struct {
|
||||||
|
|
|
@ -40,8 +40,7 @@ func (fc *fileCache) init(home string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fc *fileCache) close() {
|
func (fc *fileCache) close() {
|
||||||
fc.set("hello", "world", 200)
|
if dump, err := json.MarshalIndent(fc.cache.list(), "", " "); err == nil {
|
||||||
if dump, err := json.Marshal(fc.cache.list()); err == nil {
|
|
||||||
_ = ioutil.WriteFile(fc.home+cachePath, dump, 0644)
|
_ = ioutil.WriteFile(fc.home+cachePath, dump, 0644)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
src/environment_cache_mock_test.go
Normal file
44
src/environment_cache_mock_test.go
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import mock "github.com/stretchr/testify/mock"
|
||||||
|
|
||||||
|
// MockedCache is an autogenerated mock type for the cache type
|
||||||
|
type MockedCache struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// close provides a mock function with given fields:
|
||||||
|
func (_m *MockedCache) close() {
|
||||||
|
_m.Called()
|
||||||
|
}
|
||||||
|
|
||||||
|
// get provides a mock function with given fields: key
|
||||||
|
func (_m *MockedCache) get(key string) (string, bool) {
|
||||||
|
ret := _m.Called(key)
|
||||||
|
|
||||||
|
var r0 string
|
||||||
|
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||||
|
r0 = rf(key)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Get(0).(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
var r1 bool
|
||||||
|
if rf, ok := ret.Get(1).(func(string) bool); ok {
|
||||||
|
r1 = rf(key)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Get(1).(bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
|
// init provides a mock function with given fields: home
|
||||||
|
func (_m *MockedCache) init(home string) {
|
||||||
|
_m.Called(home)
|
||||||
|
}
|
||||||
|
|
||||||
|
// set provides a mock function with given fields: key, value, ttl
|
||||||
|
func (_m *MockedCache) set(key, value string, ttl int64) {
|
||||||
|
_m.Called(key, value, ttl)
|
||||||
|
}
|
Loading…
Reference in a new issue