mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
refactor(cli): auth/workspace cleanup — record-backed token store (#37219)
Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai>
This commit is contained in:
1 parent
62ee1fff62
commit
a650ffc00a
45 files changed
+795
-620
No files matched your search
@@ -1,31 +1,13 @@
|
||||
import type { YamlStore } from '@/store/store'
|
||||
import { mkdtemp, rm } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { useTempConfigDir } from '@test/fixtures/config-dir'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isBaseError } from '@/errors/base'
|
||||
import { ErrorCode } from '@/errors/codes'
|
||||
import { ENV_CONFIG_DIR } from '@/store/dir'
|
||||
import { getConfigurationStore } from '@/store/manager'
|
||||
import { loadConfig } from './config-loader'
|
||||
|
||||
describe('loadConfig', () => {
|
||||
let dir: string
|
||||
let prevConfigDir: string | undefined
|
||||
|
||||
beforeEach(async () => {
|
||||
dir = await mkdtemp(join(tmpdir(), 'difyctl-cfg-'))
|
||||
prevConfigDir = process.env[ENV_CONFIG_DIR]
|
||||
process.env[ENV_CONFIG_DIR] = dir
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
if (prevConfigDir === undefined)
|
||||
delete process.env[ENV_CONFIG_DIR]
|
||||
else
|
||||
process.env[ENV_CONFIG_DIR] = prevConfigDir
|
||||
await rm(dir, { recursive: true, force: true })
|
||||
})
|
||||
useTempConfigDir('difyctl-cfg-')
|
||||
|
||||
it('returns found:false when config is missing', () => {
|
||||
const r = loadConfig(getConfigurationStore())
|
||||
|
||||
Reference in new issue
Block a user