config.local.example.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * api-test 本机配置模板。复制成 config.local.php 再填(已 gitignore,不要提交):
  4. *
  5. * cp config.local.example.php config.local.php
  6. *
  7. * 切 server 两种方式(账号 / 种子数据都会跟着走):
  8. * 1. 改 `$server` 默认值;
  9. * 2. `php run.php --server=<alias>` 临时切,alias 见 config.php 的 servers 列表。
  10. * 每个 server 一套账号 + 种子数据,集中列在 `$servers`,互不干扰。
  11. * 优先级:命令行参数 > 环境变量(API_TEST_*)> 本文件 > config.php 默认值。
  12. * 不需要的键删掉或留 null 即可。
  13. */
  14. $server = 'local'; // local | staging | next | prod | next-cn | prod-cn
  15. $servers = [
  16. 'local' => [
  17. 'username' => 'test',
  18. 'password' => null,
  19. 'token' => null, // 填了就直接用,跳过登录
  20. // 管理员账号:只给 /v3/admin/* 用例用,与上面的测试账号分开;不配则 SKIP。
  21. // 生产上只跑只读用例,写入用例只在 config.php 的 admin_write_servers 上跑。
  22. 'admin_username' => null,
  23. 'admin_password' => null,
  24. 'admin_token' => null,
  25. 'fixtures' => [
  26. // 讨论写用例挂的句子:必须在测试账号自己的 channel 里、由测试账号编辑过
  27. // 'discussion_sentence' => 'ee5259be-5d1e-4408-a2a6-566a5773eef1',
  28. // discussion_sentence 所在的 channel(agent 授权的范围)
  29. // 'discussion_channel' => '1721b7fa-e471-46fd-b860-64b9e79d370e',
  30. // agent 代写用例:归测试账号所有的 AI 模型 uid;不给则 SKIP
  31. // 'agent_model' => null,
  32. // email-certifications「已注册邮箱」用例;不给则 SKIP
  33. // 'registered_email' => 'someone@example.com',
  34. ],
  35. ],
  36. 'staging' => [
  37. 'username' => null,
  38. 'password' => null,
  39. 'token' => null,
  40. 'fixtures' => [
  41. // 'discussion_sentence' => '',
  42. // 'discussion_channel' => '',
  43. // 'agent_model' => null,
  44. // 'registered_email' => null,
  45. ],
  46. ],
  47. 'next' => [
  48. 'username' => null,
  49. 'password' => null,
  50. 'token' => null,
  51. 'fixtures' => [],
  52. ],
  53. 'prod' => [
  54. 'username' => null,
  55. 'password' => null,
  56. 'token' => null,
  57. 'fixtures' => [],
  58. ],
  59. 'next-cn' => [
  60. 'username' => null,
  61. 'password' => null,
  62. 'admin_username' => null,
  63. 'admin_password' => null,
  64. 'token' => null,
  65. 'fixtures' => [],
  66. ],
  67. 'prod-cn' => [
  68. 'username' => null,
  69. 'password' => null,
  70. 'token' => null,
  71. 'fixtures' => [],
  72. ],
  73. ];
  74. if (! isset($servers[$server])) {
  75. throw new RuntimeException(
  76. 'config.local.php: 未知 server "' . $server . '",可选:' . implode(' / ', array_keys($servers))
  77. );
  78. }
  79. return [
  80. 'default_server' => $server,
  81. 'servers' => $servers,
  82. ];