refactor(test-utils): rename MockDirectoryOptions to CreateMockDirectoryOptions

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-06-11 13:50:39 +02:00
parent 9caeec3ef1
commit 006b3e8eff
6 changed files with 41 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-test-utils': patch
---
The type `MockDirectoryOptions` was renamed to `CreateMockDirectoryOptions` so that it's clear these options are exclusive to the mock directory factory.
+9 -6
View File
@@ -45,9 +45,15 @@ import { UserInfoService } from '@backstage/backend-plugin-api';
// @public
export function createMockDirectory(
options?: MockDirectoryOptions,
options?: CreateMockDirectoryOptions,
): MockDirectory;
// @public
export interface CreateMockDirectoryOptions {
content?: MockDirectoryContent;
mockOsTmpDir?: boolean;
}
// @public (undocumented)
export function isDockerDisabledForTests(): boolean;
@@ -136,11 +142,8 @@ export interface MockDirectoryContentOptions {
shouldReadAsText?: boolean | ((path: string, buffer: Buffer) => boolean);
}
// @public
export interface MockDirectoryOptions {
content?: MockDirectoryContent;
mockOsTmpDir?: boolean;
}
// @public @deprecated (undocumented)
export type MockDirectoryOptions = CreateMockDirectoryOptions;
// @public (undocumented)
export namespace mockServices {
@@ -0,0 +1,23 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CreateMockDirectoryOptions } from './filesystem';
/**
* @public
* @deprecated Use `CreateMockDirectoryOptions` from `@backstage/backend-test-utils` instead.
*/
export type MockDirectoryOptions = CreateMockDirectoryOptions;
@@ -347,7 +347,7 @@ class MockDirectoryImpl {
*
* @public
*/
export interface MockDirectoryOptions {
export interface CreateMockDirectoryOptions {
/**
* In addition to creating a temporary directory, also mock `os.tmpdir()` to return the
* mock directory path until the end of the test suite.
@@ -386,7 +386,7 @@ export interface MockDirectoryOptions {
* ```
*/
export function createMockDirectory(
options?: MockDirectoryOptions,
options?: CreateMockDirectoryOptions,
): MockDirectory {
const tmpDir = process.env.RUNNER_TEMP || os.tmpdir(); // GitHub Actions
const root = fs.mkdtempSync(joinPath(tmpDir, 'backstage-tmp-test-dir-'));
@@ -16,8 +16,8 @@
export {
createMockDirectory,
type CreateMockDirectoryOptions,
type MockDirectory,
type MockDirectoryOptions,
type MockDirectoryContent,
type MockDirectoryContentOptions,
type MockDirectoryContentCallback,
+1
View File
@@ -20,6 +20,7 @@
* @packageDocumentation
*/
export * from './deprecated';
export * from './cache';
export * from './database';
export * from './msw';