This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
package matchers | ||
|
||
import "testing" | ||
import ( | ||
"os" | ||
"os/exec" | ||
"testing" | ||
) | ||
|
||
func TestIsLogformat(t *testing.T) { | ||
type args struct { | ||
s string | ||
fnName := "TestIsLogformat" | ||
if IsEnvSet(fnName) { | ||
IsLogformat(GetTestArgEnv(fnName)) | ||
return | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
}{ | ||
// TODO: Add test cases. | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
IsLogformat(tt.args.s) | ||
}) | ||
|
||
cmd := exec.Command(os.Args[0], "-test.run=TestIsLogformat") | ||
cmd.Env = append(os.Environ(), "TEST_TestIsLogformat=1") | ||
err := cmd.Run() | ||
if e, ok := err.(*exec.ExitError); ok && !e.Success() { | ||
return | ||
} | ||
t.Fatalf("process ran with err %v, want exit status 1", err) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package matchers | ||
|
||
import "os" | ||
|
||
func getTestEnvName(fnName string) string { | ||
return "TEST_" + fnName | ||
} | ||
|
||
func IsEnvSet(fnName string) bool { | ||
return os.Getenv(getTestEnvName(fnName)) == "1" | ||
} | ||
|
||
func SetTestEnv(fnName string) string { | ||
return "TEST_" + fnName + "=1" | ||
} | ||
|
||
func SetTestArgEnv(fnName string, arg string) string { | ||
return "TEST_ARG_" + fnName + "=" + arg | ||
} | ||
|
||
func GetTestArgEnv(fnName string) string { | ||
return os.Getenv("TEST_ARG_" + fnName) | ||
} | ||
|
||
func GetArgCmd(fnName string) string { | ||
return "-test.run=" + fnName | ||
} |