Keine Beschreibung

flamegraph_test.go 985B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package driver
  2. import "testing"
  3. func TestGetNodeShortName(t *testing.T) {
  4. type testCase struct {
  5. name string
  6. want string
  7. }
  8. testcases := []testCase{
  9. {
  10. "root",
  11. "root",
  12. },
  13. {
  14. "syscall.Syscall",
  15. "syscall.Syscall",
  16. },
  17. {
  18. "net/http.(*conn).serve",
  19. "net/http.(*conn).serve",
  20. },
  21. {
  22. "github.com/blah/foo.Foo",
  23. "foo.Foo",
  24. },
  25. {
  26. "github.com/blah/foo_bar.(*FooBar).Foo",
  27. "foo_bar.(*FooBar).Foo",
  28. },
  29. {
  30. "encoding/json.(*structEncoder).(encoding/json.encode)-fm",
  31. "encoding/json.(*structEncoder).(encoding/json.encode)-fm",
  32. },
  33. {
  34. "github.com/blah/blah/vendor/gopkg.in/redis.v3.(*baseClient).(github.com/blah/blah/vendor/gopkg.in/redis.v3.process)-fm",
  35. "redis.v3.(*baseClient).(github.com/blah/blah/vendor/gopkg.in/redis.v3.process)-fm",
  36. },
  37. }
  38. for _, tc := range testcases {
  39. name := getNodeShortName(tc.name)
  40. if got, want := name, tc.want; got != want {
  41. t.Errorf("for %s, got %q, want %q", tc.name, got, want)
  42. }
  43. }
  44. }