(t *testing.T)
| 1077 | } |
| 1078 | |
| 1079 | func TestEncodedContextInvalid(t *testing.T) { |
| 1080 | s := RunDefaultServer() |
| 1081 | defer s.Shutdown() |
| 1082 | |
| 1083 | nc := NewDefaultConnection(t) |
| 1084 | c, err := nats.NewEncodedConn(nc, nats.JSON_ENCODER) |
| 1085 | if err != nil { |
| 1086 | t.Fatalf("Unable to create encoded connection: %v", err) |
| 1087 | } |
| 1088 | defer c.Close() |
| 1089 | |
| 1090 | type request struct { |
| 1091 | Message string `json:"message"` |
| 1092 | } |
| 1093 | type response struct { |
| 1094 | Code int `json:"code"` |
| 1095 | } |
| 1096 | req := &request{Message: "Hello"} |
| 1097 | resp := &response{} |
| 1098 | //lint:ignore SA1012 testing that passing nil fails |
| 1099 | err = c.RequestWithContext(nil, "slow", req, resp) |
| 1100 | if err == nil { |
| 1101 | t.Fatal("Expected request to fail with error") |
| 1102 | } |
| 1103 | if err != nats.ErrInvalidContext { |
| 1104 | t.Errorf("Expected request to fail with invalid context: %s", err) |
| 1105 | } |
| 1106 | } |
nothing calls this directly
no test coverage detected