mirror of
https://github.com/jimeh/go-mocktesting.git
synced 2026-02-19 11:56:39 +00:00
feat(mocktesting): initial implementation
This commit is contained in:
31
t_go116.go
Normal file
31
t_go116.go
Normal file
@@ -0,0 +1,31 @@
|
||||
//go:build go1.16
|
||||
// +build go1.16
|
||||
|
||||
package mocktesting
|
||||
|
||||
func (t *T) Setenv(key string, value string) {
|
||||
t.mux.Lock()
|
||||
defer t.mux.Unlock()
|
||||
|
||||
if t.env == nil {
|
||||
t.env = map[string]string{}
|
||||
}
|
||||
|
||||
if key != "" {
|
||||
t.env[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
// Getenv returns a map[string]string of keys/values given to Setenv().
|
||||
func (t *T) Getenv() map[string]string {
|
||||
if t.env == nil {
|
||||
t.mux.Lock()
|
||||
t.env = map[string]string{}
|
||||
t.mux.Unlock()
|
||||
}
|
||||
|
||||
t.mux.RLock()
|
||||
defer t.mux.RUnlock()
|
||||
|
||||
return t.env
|
||||
}
|
||||
Reference in New Issue
Block a user