Last active
August 29, 2015 14:07
-
-
Save tiborvass/fe382fcb926750a86dc5 to your computer and use it in GitHub Desktop.
Stupid github doesn't let me do slashes in filenames, so os-mock.go is os/mock.go and os-stdlib.go is os/stdlib.go.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All you need to do is: `go test -tags mock .` to have the mocked version. | |
package main | |
import ( | |
"fmt" | |
"testing" | |
"github.com/tiborvass/foo/os" | |
) | |
func TestFoo(t *testing.T) { | |
fmt.Println(os.Getenv("SHELL")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build mock | |
package os | |
func Getenv(key string) string { | |
return key | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build !mock | |
package os | |
import "os" | |
func Getenv(key string) string { | |
return os.Getenv(key) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment