我正在开发一个 Angular 10 应用程序,该应用程序使用HttpInterceptor向所有响应添加特定标头。不幸的是,在尝试测试此拦截器时,我不断收到以下错误:
Error: Expected one matching request for criteria "Match by function: ", found none.
Run Code Online (Sandbox Code Playgroud)
或类似的变体:
Error: Expected one matching request for criteria "Match URL: /endpoint", found none.
Run Code Online (Sandbox Code Playgroud)
我的期望是这个测试会通过,但我现在不知道为什么它不起作用。
这是我的拦截器:
Error: Expected one matching request for criteria "Match by function: ", found none.
Run Code Online (Sandbox Code Playgroud)
这是我的测试:
Error: Expected one matching request for criteria "Match URL: /endpoint", found none.
Run Code Online (Sandbox Code Playgroud)
也就是说,可能值得指出的是,我尝试应用以下资源中的解决方案但无济于事(大多数似乎与我已经拥有的类似,而且许多似乎适用于旧版本的 Angular):
HttpClient我所知道的。testing typescript angular angular-httpclient angular-httpclient-interceptors
我有一个运行 PostgreSQL 数据库的 Kubernetes 集群、一个 Grafana 仪表板和一个 Python 单次运行应用程序(构建为 Docker 映像),它在 Kubernetes 中每小时运行一次CronJob(参见下面的清单)。此外,这一切都是使用 ArgoCD 和 Istio side-car 注入进行部署的。
我遇到的问题(如标题所示)是我的 Python 应用程序无法连接到集群中的数据库。这对我来说很奇怪,因为仪表板实际上可以连接到数据库,所以我不确定 Python 应用程序可能会有什么不同。
以下是我的清单(更改了一些内容以删除可识别信息):
内容database.yaml:
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: database
name: database
spec:
replicas: 1
selector:
matchLabels:
app: database
strategy: {}
template:
metadata:
labels:
app: database
spec:
containers:
- image: postgres:12.5
imagePullPolicy: ""
name: database
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_DB
- …Run Code Online (Sandbox Code Playgroud) angular ×1
angular-httpclient-interceptors ×1
istio ×1
kubernetes ×1
postgresql ×1
python-3.x ×1
testing ×1
typescript ×1