Finding failing cases: ``` bash tree-grepper -q go '((binary_expression (identifier) ["==" "!="] (interpreted_string_literal) @ri) (#eq? @ri "\"\""))' ``` Fixing failing cases: ``` bash comby 'if :[1~[^ ]*] == ""' 'if len(:[1]) == 0' -matcher .go -in-place comby 'if :[1~[^ ]*] != ""' 'if len(:[1]) > 0' -matcher .go -in-place ``` <!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * closes https://github.com/alcionai/corso/issues/3654 #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
48 lines
841 B
Go
48 lines
841 B
Go
package tester
|
|
|
|
import (
|
|
"reflect"
|
|
"runtime"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// AreSameFunc asserts whether the two funcs are the same func.
|
|
func AreSameFunc(t *testing.T, expect, have any) {
|
|
assert.Equal(
|
|
t,
|
|
runtime.FuncForPC(
|
|
reflect.
|
|
ValueOf(expect).
|
|
Pointer()).Name(),
|
|
runtime.FuncForPC(
|
|
reflect.
|
|
ValueOf(have).
|
|
Pointer()).Name())
|
|
}
|
|
|
|
type TestT interface {
|
|
Logf(format string, args ...any)
|
|
Name() string
|
|
TempDir() string
|
|
require.TestingT
|
|
}
|
|
|
|
// LogTimeOfTest logs the test name and the time that it was run.
|
|
func LogTimeOfTest(t TestT) string {
|
|
now := time.Now().UTC().Format(time.RFC3339Nano)
|
|
name := t.Name()
|
|
|
|
if len(name) == 0 {
|
|
t.Logf("Test run at %s.", now)
|
|
return now
|
|
}
|
|
|
|
t.Logf("%s run at %s", name, now)
|
|
|
|
return now
|
|
}
|