()
| 1886 | } |
| 1887 | |
| 1888 | func (s *SQLTestSuite) Test_Issue565() { |
| 1889 | _, err := s.Session().Collection("birthdays").Insert(&birthday{ |
| 1890 | Name: "Lucy", |
| 1891 | Born: time.Now(), |
| 1892 | }) |
| 1893 | s.NoError(err) |
| 1894 | |
| 1895 | ctxKeyCarry := db.ContextKey("carry") |
| 1896 | |
| 1897 | parentCtx := context.WithValue(s.Session().Context(), ctxKeyCarry, 1) |
| 1898 | s.NotZero(parentCtx.Value(ctxKeyCarry)) |
| 1899 | |
| 1900 | { |
| 1901 | ctx, cancel := context.WithTimeout(parentCtx, time.Nanosecond) |
| 1902 | defer cancel() |
| 1903 | |
| 1904 | sess := s.Session() |
| 1905 | |
| 1906 | sess = sess.WithContext(ctx) |
| 1907 | |
| 1908 | var result birthday |
| 1909 | err := sess.Collection("birthdays").Find().Select("name").One(&result) |
| 1910 | |
| 1911 | s.Error(err) |
| 1912 | s.Zero(result.Name) |
| 1913 | |
| 1914 | s.NotZero(ctx.Value(ctxKeyCarry)) |
| 1915 | } |
| 1916 | |
| 1917 | { |
| 1918 | ctx, cancel := context.WithTimeout(parentCtx, time.Second*10) |
| 1919 | cancel() // cancel before passing |
| 1920 | |
| 1921 | sess := s.Session().WithContext(ctx) |
| 1922 | |
| 1923 | var result birthday |
| 1924 | err := sess.Collection("birthdays").Find().Select("name").One(&result) |
| 1925 | |
| 1926 | s.Error(err) |
| 1927 | s.Zero(result.Name) |
| 1928 | |
| 1929 | s.NotZero(ctx.Value(ctxKeyCarry)) |
| 1930 | } |
| 1931 | |
| 1932 | { |
| 1933 | ctx, cancel := context.WithTimeout(parentCtx, time.Second) |
| 1934 | defer cancel() |
| 1935 | |
| 1936 | sess := s.Session().WithContext(ctx) |
| 1937 | |
| 1938 | var result birthday |
| 1939 | err := sess.Collection("birthdays").Find().Select("name").One(&result) |
| 1940 | |
| 1941 | s.NoError(err) |
| 1942 | s.NotZero(result.Name) |
| 1943 | |
| 1944 | s.NotZero(ctx.Value(ctxKeyCarry)) |
| 1945 | } |
nothing calls this directly
no test coverage detected