mirror of
https://github.com/rancher/norman.git
synced 2025-07-06 20:10:09 +00:00
add a method to check if the error message contains a tmp file path. It is to prevent updating resource's condition forever and causing the controller flapping. https://github.com/rancher/rancher/issues/15103
20 lines
425 B
Go
20 lines
425 B
Go
package condition
|
|
|
|
import "testing"
|
|
|
|
func TestRegexp(t *testing.T) {
|
|
testInputs := []string{
|
|
"create file /tmp/file-uy76324 ",
|
|
"/tmp/file-y6123tsd",
|
|
}
|
|
testOutputs := []string{
|
|
"create file file_path_redacted ",
|
|
"file_path_redacted",
|
|
}
|
|
for i, s := range testInputs {
|
|
if testOutputs[i] != temfileRegexp.ReplaceAllString(s, "file_path_redacted") {
|
|
t.Fatalf("Regexp failed to check %s", testInputs[i])
|
|
}
|
|
}
|
|
}
|