refactor: split node agent and Go control plane

This commit is contained in:
2026-09-11 16:57:31 +08:00
parent 078c22c73b
commit c86ba9c4d7
129 changed files with 654 additions and 77 deletions
@@ -13,6 +13,6 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\WxAgent.Core\WxAgent.Core.csproj" />
<ProjectReference Include="..\..\..\node-agent\WxAgent.Core\WxAgent.Core.csproj" />
</ItemGroup>
</Project>
@@ -5,6 +5,6 @@
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.28" />
<ProjectReference Include="../../src/WxAgent.Service/WxAgent.Service.csproj" />
<ProjectReference Include="../../../node-agent/WxAgent.Service/WxAgent.Service.csproj" />
</ItemGroup>
</Project>
@@ -5,24 +5,24 @@ import sqlite3
from pathlib import Path
source = (
Path(__file__).resolve().parents[1] / "src/WxAgent.Core/WechatContactQuery.cs"
Path(__file__).resolve().parents[2] / "node-agent/WxAgent.Core/WechatContactQuery.cs"
).read_text()
match = re.search(r'public const string Sql = """\s*(.*?)\s*""";', source, re.S)
assert match is not None
sql = match.group(1)
with sqlite3.connect(":memory:") as db:
db.execute(
with sqlite3.connect(":memory:") as connection:
connection.execute(
"CREATE TABLE contact(username TEXT PRIMARY KEY, nick_name TEXT, remark TEXT, small_head_url TEXT)"
)
db.executemany(
connection.executemany(
"INSERT INTO contact VALUES (?, ?, ?, NULL)",
[(f"wxid_{i:04}", "same display name", None) for i in range(501)]
+ [("room@chatroom", "group", None), ("literal", "O'Brien_%", None)],
)
def query(limit=201, offset=0, contains=None, groups=None):
return db.execute(
return connection.execute(
sql, {"limit": limit, "offset": offset, "contains": contains, "groups": groups}
).fetchall()
@@ -38,7 +38,7 @@ with sqlite3.connect(":memory:") as db:
assert len(query(limit=10000, groups=0)) == 502
assert len(query(limit=10000, contains="same display name")) == 501
assert query(offset=503) == []
assert db.execute("SELECT count(*) FROM contact").fetchone()[0] == 503
assert connection.execute("SELECT count(*) FROM contact").fetchone()[0] == 503
print(
"contact SQL: pagination, duplicate names, literal filtering and group filtering passed"