(t *testing.T)
| 886 | } |
| 887 | |
| 888 | func TestHasNeighborsWithContext(t *testing.T) { |
| 889 | type key string |
| 890 | ctx := context.WithValue(context.Background(), key("mykey"), "myval") |
| 891 | for _, rel := range [...]Rel{M2M, O2M, O2O} { |
| 892 | t.Run(rel.String(), func(t *testing.T) { |
| 893 | sel := sql.Dialect(dialect.Postgres). |
| 894 | Select("*"). |
| 895 | From(sql.Table("users")). |
| 896 | WithContext(ctx) |
| 897 | step := NewStep( |
| 898 | From("users", "id"), |
| 899 | To("groups", "id"), |
| 900 | Edge(rel, false, "user_groups", "user_id", "group_id"), |
| 901 | ) |
| 902 | var called bool |
| 903 | pred := func(s *sql.Selector) { |
| 904 | called = true |
| 905 | got := s.Context().Value(key("mykey")).(string) |
| 906 | require.Equal(t, "myval", got) |
| 907 | } |
| 908 | HasNeighborsWith(sel, step, pred) |
| 909 | require.True(t, called, "expected predicate function to be called") |
| 910 | }) |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | func TestOrderByNeighborsCount(t *testing.T) { |
| 915 | build := sql.Dialect(dialect.Postgres) |
nothing calls this directly
no test coverage detected
searching dependent graphs…