(t *testing.T)
| 850 | } |
| 851 | |
| 852 | func TestGetMsg(t *testing.T) { |
| 853 | tests := []struct { |
| 854 | name string |
| 855 | seq uint64 |
| 856 | opts []jetstream.GetMsgOpt |
| 857 | expectedData string |
| 858 | expectedHeaders nats.Header |
| 859 | timeout time.Duration |
| 860 | withError error |
| 861 | }{ |
| 862 | { |
| 863 | name: "get existing msg", |
| 864 | seq: 2, |
| 865 | timeout: 5 * time.Second, |
| 866 | expectedData: "msg 1 on subject B", |
| 867 | }, |
| 868 | { |
| 869 | name: "with empty context", |
| 870 | seq: 2, |
| 871 | expectedData: `msg 1 on subject B`, |
| 872 | }, |
| 873 | { |
| 874 | name: "get deleted msg", |
| 875 | seq: 3, |
| 876 | withError: jetstream.ErrMsgNotFound, |
| 877 | }, |
| 878 | { |
| 879 | name: "get non existing msg", |
| 880 | seq: 50, |
| 881 | withError: jetstream.ErrMsgNotFound, |
| 882 | }, |
| 883 | { |
| 884 | name: "with next for subject", |
| 885 | seq: 1, |
| 886 | opts: []jetstream.GetMsgOpt{jetstream.WithGetMsgSubject("*.C")}, |
| 887 | expectedData: "msg with headers", |
| 888 | expectedHeaders: map[string][]string{ |
| 889 | "X-Nats-Test-Data": {"test_data"}, |
| 890 | "X-Nats-Key": {"123"}, |
| 891 | }, |
| 892 | }, |
| 893 | { |
| 894 | name: "get msg with headers", |
| 895 | seq: 9, |
| 896 | expectedData: "msg with headers", |
| 897 | expectedHeaders: map[string][]string{ |
| 898 | "X-Nats-Test-Data": {"test_data"}, |
| 899 | "X-Nats-Key": {"123"}, |
| 900 | }, |
| 901 | }, |
| 902 | { |
| 903 | name: "context timeout", |
| 904 | seq: 1, |
| 905 | timeout: 1 * time.Microsecond, |
| 906 | withError: context.DeadlineExceeded, |
| 907 | }, |
| 908 | } |
| 909 |
nothing calls this directly
no test coverage detected